3

I have a flask app running in a docker container, and I configured nginx to redirect all requests to this container. Here's my nginx config:

server {
  listen 80;
  location / {
    proxy_pass http://127.0.0.1:5000;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection "Keep-Alive";
    proxy_set_header Proxy-Connection "Keep-Alive";
    proxy_read_timeout 60s;
  }
}

On the frontpage I have a link to a subdirectory <a href="/sub/dir/">Test</a>, and when the page renders I can see it links to http://example.com/sub/dir. However when I click onto it browser shows http://127.0.0.1:5000/sub/dir and tries to reach my local.

Suanmeiguo
  • 141
  • 4

1 Answers1

1

Thanks for the help from @Shane I found why.

My flask app have a redirect on that link to another page, after adding this to my nginx config it worked for me:

proxy_set_header Host $Host;
Suanmeiguo
  • 141
  • 4