NGINX configuration: use relative redirects

Use relative redirects to account for situations where a front-end
proxy is used and the container does not know the public domain and
port.

Before this change, when running locally (on localhost:4000), redirects would omit
the port number, and redirect to localhost _without_ port number:

    curl -v "http://localhost:4000/engine/reference/commandline/run"
    * TCP_NODELAY set
    * Connected to localhost (::1) port 4000 (#0)
    > GET /engine/reference/commandline/run HTTP/1.1
    > Host: localhost:4000
    > User-Agent: curl/7.65.3
    > Accept: */*
    >
    * Mark bundle as not supporting multiuse
    < HTTP/1.1 301 Moved Permanently
    < Server: nginx/1.17.8
    < Date: Fri, 28 Feb 2020 13:46:10 GMT
    < Content-Type: text/html
    < Content-Length: 169
    < Location: http://localhost/engine/reference/commandline/run/
    < Connection: keep-alive

After this change, redirect will be "relative", so redirecting to the correct location:

    curl -v "http://localhost:4000/engine/reference/commandline/run"
    * TCP_NODELAY set
    * Connected to localhost (::1) port 4000 (#0)
    > GET /engine/reference/commandline/run HTTP/1.1
    > Host: localhost:4000
    > User-Agent: curl/7.65.3
    > Accept: */*
    >
    * Mark bundle as not supporting multiuse
    < HTTP/1.1 301 Moved Permanently
    < Server: nginx/1.17.8
    < Date: Fri, 28 Feb 2020 13:39:02 GMT
    < Content-Type: text/html
    < Content-Length: 169
    < Connection: keep-alive
    < Location: /engine/reference/commandline/run/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-02-28 14:27:11 +01:00
parent 820a2242d1
commit a94d10bdd2
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,7 @@
server {
port_in_redirect off;
# Use relative redirects to account for situations where a front-end proxy is
# used and the container does not know the public domain and port
absolute_redirect off;
listen 4000;
error_page 403 404 /404.html;
location / {