beyondcode / herd-community

79 stars 1 forks source link

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

Closed godismyjudge95 closed 1 day ago

godismyjudge95 commented 1 month ago

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)
jerrens commented 1 month ago

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...
  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
  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
zarulizham commented 1 month ago

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.