0

I have this config

server {
  listen 8080;
  access_log  /var/log/nginx/access.log;
  root        /usr/share/nginx/htdocs;
  index       index.html index.htm;
  port_in_redirect off;

  location /somepath/ {
      proxy_pass http://someinternalserver/somepath/;
  }

  location /health {
    return 200;
  }
}

When I access it like this, http://our-external-fqdn/somepath/ it works.

However, when I access it like this, http://our-external-fqdn/somepath/# I get redirected to our local development setup which is http://localhost:8000

What am I missing?

devwannabe
  • 181
  • 2
  • 13

1 Answers1

0

You've specified an exact URL not a regular expression. Try this

location ~* /somepath/ {
  proxy_pass http://someinternalserver/somepath/;
}

If that doesn't work please curl (with show headers, option is -D I think) the URL to see what's going on, or use Firefox with "Live HTTP Headers". Post the output for that request along with your access logs.

Tim
  • 30,383
  • 6
  • 47
  • 77
  • I got an error after I restarted nginx - nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in /usr/local/etc/nginx/nginx.conf:138 – devwannabe Apr 27 '16 at 20:04
  • Edit your original question to include your your nginx.conf and and site configuration files. Add this to the bottom of your original post, don't replace your original question. I think though my answer is incorrect, and that you may need to go back to the original configuration. I use fastcgi_pass with regular expression matches, but not proxy_pass. Suggest you do my "if that doesn't work" and post that information as well. – Tim Apr 27 '16 at 20:17
  • Also, read this, which says remove the trailing slash from the end of your proxy_pass statement http://serverfault.com/questions/649151/nginx-location-regex-doesnt-work-with-proxy-pass – Tim Apr 27 '16 at 20:18
  • Tim, that's all my nginx.conf file. It's really that simple. – devwannabe Apr 27 '16 at 20:28
  • i removed the trailing slash but I still got the same error – devwannabe Apr 27 '16 at 20:34
  • Revert the changes and do my "if that doesn't work". Post the result in your first post under the existing text. – Tim Apr 27 '16 at 20:37