I'm trying to use pass traffic which is going to www.example.com/subfolder to a standalone application running on the same machine. Here is what I have:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location /loc {

                proxy_pass "";

        location /loc1 {

                proxy_pass "";

        location /loc2 {

                proxy_pass "";

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;


Visiting www.example.com/loc after running nginx -s reload returns a 404. What am I doing wrong?

  • Lets get the easy stuff out of the way. Have you restarted nginx after making configuration changes to it? – Stephen Ostermiller May 4 '18 at 16:27
  • Does visiting http://www.example.com/ show the correct index.html file from your server? – Stephen Ostermiller May 4 '18 at 16:28
  • 1
    Have you tried location /loc/ (including the trailing slash)? Some of the examples I'm finding use the trailing slash: liaohuqiu.net/posts/nginx-proxy-pass – Stephen Ostermiller May 4 '18 at 16:29
  • I've updated the question to clarify. Yes I've restarted nginx, index.html is showing up as expected, I will try with the trailing slash in case that helps. EDIT: trailing slash didn't change anything. – Tallone55 May 4 '18 at 16:37
  • The example I linked to doesn't have quotes around the URLs. If that doesn't make a difference, then I'm out of ideas. I'm sure there is somebody here that knows more about nginx than I do that can help. – Stephen Ostermiller May 4 '18 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.