nginx location path with proxy_pass

前端 未结 1 1791
野性不改
野性不改 2020-12-16 02:16

I have following problem, i\'m trying to put a Django app with an gunicorn server on my VPS running Nginx. My nginx config looks like this:

upstream app_name         


        
相关标签:
1条回答
  • 2020-12-16 03:00

    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/;
    
    }
    
    0 讨论(0)
提交回复
热议问题