h5bp / server-configs-nginx

Nginx HTTP server boilerplate configs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

404 proxy error

DrTrills opened this issue · comments

Hey team,

I am currently have apache2 running as a proxy for a Java Jetty app. I want to switch from Apache to nginx and have run into some issues. When creating a new site-available/enabled and adding the proxypass server block I get 404 errors. When I add the same block to nginx.conf in the http {} I get the proxy to work. Is there any advice or suggestions on getting this to work without modifying nginx.conf and using the best practice sites-enabled/available.

Here is the code I am using successfully in nginx.conf and unsuccessfully in sites-enabled:

    server {
        listen          80;
        server_name     _;
        location / {
                proxy_pass      http://localhost:8000;
                proxy_redirect  off;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

Thanks!

When I add the same block to nginx.conf in the http {} I get the proxy to work

Sounds like the nginx file you are using does not include this line

Closing as the question does not seem likely to be related to this repo.