I have setup a reverse proxy, sending requests from nginx (openresty) to apache, using this is only to allow more control through openresty to check the requests, but essentially the server is running on apache.
The problem is that apache is on port 8080, and nginx on 80, so whenever apache does a redirect it redirects to port 8080 and I have not found any conclusive way to prevent this and instead have it go to port 80.
My server config for nginx is the following
server {
listen 80 default_server;
server_name localhost;
client_max_body_size 1024m;
client_body_timeout 300s;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
No lua added yet though.
As for Apache:
<VirtualHost *:8080>
UseCanonicalName Off
ServerName domain.com
ServerAdmin [email protected]
DocumentRoot /home/user1/environments/production
</VirtualHost>
<VirtualHost *:8080>
ServerAlias *.*.domain.com
VirtualDocumentRoot /home/%2/environments/%1
</VirtualHost>
<VirtualHost *:8080>
ServerAlias *.domain.com
VirtualDocumentRoot /home/%1/environments/production
</VirtualHost>
This works but if apache does any sort of redirect it redirects though port 8080. I effectively want to close off port 8080 from being accessed through anything other then nginx, but through nginx apache should be running as if it were also on port 80.
I noticed after playing around that regardless of using the proxy in nginx or not, it would redirect.
This told me there must be some sort of caching interfering, but I had browser cache disabled the entire time.
So I am not entirely sure what fixed it, but all I updated was my location block as follows:
This is after around 6-8 hours of scouring google and trying different things. After trying to clear it all out and just output hello world from nginx I seen it was still redirecting.
Trying an incognito window managed to stop the redirect, so if you try this solution do not depend on disabling cache, as it seems only incognito stops it from caching the redirect in this instance (at least in chrome 61). Also other updates to the server config takes effect, just not the redirect.
I am thinking
Are the most likely to have resolved the original issue.