Control Web Panel

WebPanel => How to => Topic started by: bullten on August 15, 2018, 01:34:51 PM

Title: [Solution] Nginx + Varnish + Apache force SSL .htaccess Redirect Loops
Post by: bullten on August 15, 2018, 01:34:51 PM
Whenever you are using [Nginx + Varnish + Apache] or [Nginx + Apache] you need to tell Apache that a SSL request is being served by a proxy server. So use the code below to force SSL .htaccess

Code: [Select]
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IFModule>
Title: Re: [Solution] Nginx + Varnish + Apache force SSL .htaccess Redirect Loops
Post by: tutods on September 27, 2018, 03:35:21 PM
Hi.
Where i put this code?
With this code all domains redirect to https?
Title: Re: [Solution] Nginx + Varnish + Apache force SSL .htaccess Redirect Loops
Post by: GTMAN on December 03, 2018, 03:59:41 PM
Hi.
Where i put this code?
With this code all domains redirect to https?

.htaccess file.
Title: Re: [Solution] Nginx + Varnish + Apache force SSL .htaccess Redirect Loops
Post by: monkeyking on December 03, 2018, 04:23:24 PM
Whenever you are using [Nginx + Varnish + Apache] or [Nginx + Apache] you need to tell Apache that a SSL request is being served by a proxy server. So use the code below to force SSL .htaccess

Code: [Select]
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IFModule>

This work great! Is possible to do this through vhost on the server side so we don't have to add this every time?
Title: Re: [Solution] Nginx + Varnish + Apache force SSL .htaccess Redirect Loops
Post by: studio4host on December 03, 2018, 09:49:38 PM
I would suggest contacting cwp support to check it and they could integrate permanent solution if some issue exists.

main instructions
http://wiki.centos-webpanel.com/webservers-vhost-templates
http://wiki.centos-webpanel.com/webservers-update
http://forum.centos-webpanel.com/high-performance/wordpress-high-performance-instructions/
Title: Re: [Solution] Nginx + Varnish + Apache force SSL .htaccess Redirect Loops
Post by: monkeyking on December 04, 2018, 04:24:33 AM
Thank for the idea. I've contacted them just now. Can you also do so too and anyone else? Hopefully they will see it's important. This cause redirect issues and app breaks because of the mixed content.