Author Topic: [BUG] Nginx + Apache Force HTTPS (Redirect Loop)  (Read 5579 times)

0 Members and 1 Guest are viewing this topic.

Offline
***
[BUG] Nginx + Apache Force HTTPS (Redirect Loop)
« 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

Code: [Select]
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

Code: [Select]
proxy_pass http://xxx.xxx.xxx.xxx:8181;
We need to replace http with https and port 8181 with 8443

Code: [Select]
proxy_pass https://xxx.xxx.xxx.xxx:8443;
Restart Nginx

Code: [Select]
service nginx restart

Offline
*
Re: [BUG] Nginx + Apache Force HTTPS (Redirect Loop)
« Reply #1 on: April 10, 2019, 09:10:25 AM »
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?

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

Code: [Select]
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

Code: [Select]
proxy_pass http://xxx.xxx.xxx.xxx:8181;
We need to replace http with https and port 8181 with 8443

Code: [Select]
proxy_pass https://xxx.xxx.xxx.xxx:8443;
Restart Nginx

Code: [Select]
service nginx restart