herd-community icon indicating copy to clipboard operation
herd-community copied to clipboard

[Bug]: Windows herd proxy command creates invalid NGINX config

Open godismyjudge95 opened this issue 1 year ago • 2 comments

Platform

Windows

Operating system version

Windows 11 Pro (22631.3880)

System architecture

Intel (x86)

Herd Version

1.9.0

PHP Version

No response

Bug description

Creating a proxy using the herd proxy command causes it to create a new NGINX site config that then causes NGINX to not boot because there is an error in it.

The solution is quite simple, we just need to change the path from:

error_log "C:/Users/user/.config/herd/config/valet/Log/reverb.test-error.log"

To:

error_log "C:/Users/user/.config/herd/Log/reverb.test-error.log"

Steps to reproduce

  1. Run herd proxy --secure reverb.test https://localhost:8080
  2. Check the Herd dashboard
  3. Notice that NGINX cannot start
  4. Click the (i) to see the NGINX logs you will see an error like the below

Relevant log output

2024/07/29 00:11:29 [emerg] 32648#4056: CreateFile() "C:/Users/user/.config/herd/config/valet/Log/reverb.test-error.log" failed (3: The system cannot find the path specified)

godismyjudge95 avatar Jul 29 '24 04:07 godismyjudge95

I was experiencing the same problem and the fix suggested by @godismyjudge95 is working for me to get NGinX running again, but I still needed to manually add my new proxy domain into my Windows hosts file.

My proxy is not listed in the output of herd proxies either.

Steps (Win10, Herd v1.9.0):

  1. Add Herd Proxy
C:\>herd proxy testServer http://127.0.0.1:8025
Valet will now proxy [http://testServer.test] traffic to [http://localhost:8025].
Restarting NGINX...
  • [ ] BUG: NGinX service in Herd did not restart because of the invalid path referenced for the error_log in the NGinX config file that was generated.

  • [ ] FEATURE REQUEST: An error message or confirmation would be nice on the previous command output to inform the user that the NGinX service failed to start.

  1. Fix proxy config
  • Either:

    • Create %USERPROFILE%/.config/herd/config/valet/Log/ directory (this must only be done once)
    • Edit %USERPROFILE%\.config\herd\config\valet\Nginx\testServer.test.conf to change the error_log paths (lines 18 and 65) to a directory that exists (this would be required for each proxy
  • Once the above has been done, run herd restart

  • [ ] BUG: The new proxy does not appear when running herd proxies

  1. Manually add entry to hosts
  • Edit the file C:\Windows\System32\drivers\etc\hosts (in Admin mode) to add the proxy reference

    • 127.0.0.1 testServer.test
  • After saving this change, I am able to successfully browse to http://testServer.test

  • [ ] BUG: herd proxy... commands should create an entry in the hosts file

jerrens avatar Aug 02 '24 12:08 jerrens

I'm encountered the same issues on MacOS.

For MacOS:

Navigate to proxy configuration file: /Users/<YOUR_USER>/Library/Application Support/Herd/config/valet/Nginx

From: error_log "/Users/<YOUR_USER>/Library/Application Support/Herd/config/valet/Log/<YOUR_PROXY>.test-error.log";

To: error_log "/Users/<YOUR_USER>/Library/Application Support/Herd/Log/<YOUR_PROXY>.test-error.log";

After saved, restart Herd and you can access the URL.

zarulizham avatar Aug 04 '24 07:08 zarulizham