0

I've got an nginx server listening on port 5015 (on my domain, http://foobar.com; that is, the URL is http://foobar.com:5015), proxying to a flask app on port 8095, with this in my nginx config file:

server {

    listen 5015;
    server_name foobar.com;

    client_max_body_size 100M;
    location / {


        proxy_pass http://127.0.0.1:8095/;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_cache cache;
        proxy_cache_bypass $cookie_auth_tkt;
        proxy_no_cache $cookie_auth_tkt;
        proxy_cache_valid 30m;
        proxy_cache_key $host$scheme$proxy_host$request_uri;
    }

}

it all works well, but I'd like to print the full URL (including port number) in flask on the index page. I've tried all the properties in this answer, but only foobar.com is ever printed.

I'm pretty confused by this.

For request.host, the docs say:

The host name the request was made to, including the port if it’s non-standard.

Neither 5015 (if it's using the nginx URL), nor 8095 (if it's using the proxy URL) are standard ports (as far as I know!).

Can someone explain what's going on, and if it's possible to get flask to print http://foobar.com:5015 from any of the Request properties?

ChrisW
  • 4,783
  • 7
  • 52
  • 86

0 Answers0