[Solved]-Nginx location path with proxy_pass

19👍

You just need a trailing slash for proxy_pass:

proxy_pass http://app_name/;

it helps you to cut the “appname” prefix so the config looks like:

upstream app_name {
    server unix:/path/to/socket/file.sock fail_timeout=10;
}

server {

   listen 80 default_server;
   listen[::]:80 default_server ipv6only=on;
   root /webapps/;
   server_name my_hostname.com;

   location /appname/ {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;

      proxy_pass http://app_name/;

}

Leave a comment