blacklabelops-legacy / nginx

Dockerized Ready-To-Go Nginx Reverse Proxy. Let's encrypt Support!
MIT License
95 stars 41 forks source link

replace the part of the request URI that matches the location parameter #28

Closed wivaku closed 6 years ago

wivaku commented 7 years ago

The nginx documentation describes the functionality as I would expect it:

location /some/path/ {
    proxy_pass http://www.example.com/link/;
}

Note the trailing / at the end of the proxy_pass URL. This correctly replaces the part of the request URI that matches the location parameter:

myproxy.com/some/path/page.html --> www.example.com/link/page.html

But, when using:

$ docker run -d \
    -p 80:80 \
    --name nginx \
    -e "SERVER1REVERSE_PROXY_LOCATION1=/some/path/" \
    -e "SERVER1REVERSE_PROXY_PASS1=http://www.example.com/link/" \
    blacklabelops/nginx

The original URI is added to the URI of the upstream: myproxy.com/some/path/page.html --> www.example.com/link//some/path2/page.html

blacklabelops commented 6 years ago

As a workaround I have added a failsafe switch in order to deactivate the internal resolver. Background: The resolver is responsible for resolving the host in periodical intervals. I have added this on order to reroute to restarted docker containers with new ip.

The switch is the environment variable REVERSE_PROXY_DISABLE_RESOLVER. Value: true or false (Default: false). Will switch back to nginx default behavior for this proxy.

Example:

docker run -d \
    -p 80:80 \
    --name nginx \
    -e "SERVER1REVERSE_PROXY_LOCATION1=/" \
    -e "SERVER1REVERSE_PROXY_PASS1=http://www.heise.de" \
    -e "SERVER1REVERSE_PROXY_DISABLE_RESOLVER1=true" \
    blacklabelops/nginx
blacklabelops commented 6 years ago

Should now even work without disabling resolver!