I
I
Ivan2020-06-02 20:51:58
Django
Ivan, 2020-06-02 20:51:58

Why is the port not passed?

Hello. There is an Nginx configuration

upstream web {
    server web:8083;
}
upstream project {
    server web_project:8088;
}
upstream daphne {
    server daphne:8001;
}
server {

    listen 80;



    location /ws/ {
        try_files $uri @proxy_to_ws;
    }

    location /api/v1/project/ {
        try_files $uri @proxy_to_project;
    }

    location / {
        try_files $uri @proxy_to_web;
    }

    location @proxy_to_ws {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
        proxy_pass   http://daphne;
    }

    location @proxy_to_web {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_pass http://web;

    }

    location @proxy_to_project {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_pass http://project;

    }


    location /media {
        alias /web/server-static/;
    }
    location /static {
        alias /web/static/;
    }


}

When a request is sent and the request contains the Host web.com:8000 header, for some reason, only web.com is displayed in the application without a port. Tell me, please, can I somehow make it so that the port is also transmitted? Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question