[BUG] Nginx + Apache Force HTTPS (Redirect Loop)

Started by bullten, August 12, 2018, 05:05:44 PM

Previous topic - Next topic

bullten

Hello,

If you force https in htaccess when you are using Apache+Nginx as reverse proxy you may end up with redirect loop.

Redirect code .htaccess

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Using the above code will end up with redirect loop

Its because Vhost of nginx ssl is not passing correct parameter for proxy_pass

Right now what we have

proxy_pass http://xxx.xxx.xxx.xxx:8181;

We need to replace http with https and port 8181 with 8443

proxy_pass https://xxx.xxx.xxx.xxx:8443;

Restart Nginx

service nginx restart


asrof_id

Hi Bullten,

1. when I edit htaccess file to redirect ssl
2. website often shows "too many redirect"
3. is this what you mean ?
4. Could you tell us what file I should  edit?

Quote from: bullten on August 12, 2018, 05:05:44 PM
Hello,

If you force https in htaccess when you are using Apache+Nginx as reverse proxy you may end up with redirect loop.

Redirect code .htaccess

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Using the above code will end up with redirect loop

Its because Vhost of nginx ssl is not passing correct parameter for proxy_pass

Right now what we have

proxy_pass http://xxx.xxx.xxx.xxx:8181;

We need to replace http with https and port 8181 with 8443

proxy_pass https://xxx.xxx.xxx.xxx:8443;

Restart Nginx

service nginx restart