Control Web Panel
WebPanel => How to => Topic started 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
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>
-
Hi.
Where i put this code?
With this code all domains redirect to https?
-
Hi.
Where i put this code?
With this code all domains redirect to https?
.htaccess file.
-
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
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?
-
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/
-
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.
-
Hello,
I know this issue, and i cant fix not yet but you can use temporary fix :
If you using only Apache, you can use this code for HTTPS redirecting in .htaccess file :
# Before evereything, redirect HTTPS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L,E=HTTPS:1]
</IfModule>
If you using NGINX + APACHE with reverse proxy etc. you can use this code for HTTPS redirecting in .htaccess file :
# NGINX + APACHE Before evereything, redirect HTTPS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# If you want www redirect..
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L,E=HTTPS:1]
</IfModule>
-
I don't know why you are using .htaccess for forcing https if you are using nginx.
Nginx is not working with .htaccess and so it is not taking all the code like if you are using apache alone.
To really force https instead of make a redirect, you better configure this in the webserver Main or Domain Config.
Select the user you wanna force, create a template and select "force-https" as nginx default vhost template.
This will do the real force of https instead of first use http and redirect a user to https and it is persistant for updates.
This is the way i use it and i never faced any problems with all my sites.
If you wanna force all users to only use HTTPS, configure this in the webservers main config.
-
I tried this solution:
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>
But I have the same problem in some moments. it's extrange.
REgards.
https://alcazardesanjuan.com
-----------
Aśn le persiste el problema? me pasa lo mismo al utilizar nginx-varnish-apache, le siguió sucediendo o ya solucionó de otra manera?
Yo acabo de poner el codigo en el archivo htacess espero funcione.