Как настроить редирект http на https в ISPManager 4?
Нужно сделать редирект с http https версию сайта. Сайт Wordpress 4.1, VPS на DigitalOcean, ISPManager 4.
Бэкэнд — Апач, Фронтенд- nginx.
После долгих мучений получилось отредиректить все страницы сайта кроме главной, собственно в этом и проблема. На главной циклическая переадресация.
Конфиг nginx
server { server_name example.com.ua www.example.com.ua; listen 95.34.6.59:80; rewrite ^ https://$host$request_uri? permanent; disable_symlinks if_not_owner from=$root_path; index index.php; set $root_path /bla/bla/example.com.ua; location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/example.com.ua.access.log; error_page 404 = @fallback; } location / { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location @fallback { proxy_pass 95.85.6.59:81; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^.+\.(html|jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|ttf|woff|otf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/access.log; error_page 404 = @fallback; } location ^~ /webstat/ { auth_basic «Restricted area»; auth_basic_user_file /bla/bla/data/etc/802063.passwd; try_files $uri @fallback; } include /bla/bla/etc/nginx.inc; } server { server_name example.com.ua www.example.com.ua; listen 95.85.6.59:443 ssl; disable_symlinks if_not_owner from=$root_path; index index.php; set $root_path /bla/bla/www/example.com.ua; location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/example.com.ua.access.log; error_page 404 = @fallback; } location / { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location @fallback { proxy_pass 95.85.6.59:81; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^.+\.(html|jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|ttf|woff|otf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/access.log; error_page 404 = @fallback; } location ^~ /webstat/ { auth_basic «Restricted area»; auth_basic_user_file /bla/bla/data/etc/802063.passwd; try_files $uri @fallback; } include /usr/local/ispmgr/etc/nginx.inc; ssl_certificate /bla/bla/fhggf.crt; ssl_certificate_key /bla/bla/httpd-cert/fghfd.key; }
конфиг apache
ServerName example.com.ua CustomLog /var/www/httpd-logs/example.com.ua.access.log combined DirectoryIndex index.php DocumentRoot /bla/bla/data/www/example.com.ua ErrorLog /var/www/httpd-logs/example.com.ua.error.log ServerAdmin info@example.com.ua ServerAlias www.example.com.ua SuexecUserGroup domains domains AddHandler fcgid-script .php .php3 .php4 .php5 .phtml ScriptAlias /cgi-bin/ /bla/bla/data/www/example.com.ua/cgi-bin/
.htaccess
RewriteEngine On RewriteRule ^index\.php$ — [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule. /index.php [L] RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI}
Мучаюсь 3 день уже.
Бэкэнд — Апач, Фронтенд- nginx.
После долгих мучений получилось отредиректить все страницы сайта кроме главной, собственно в этом и проблема. На главной циклическая переадресация.
Конфиг nginx
server { server_name example.com.ua www.example.com.ua; listen 95.34.6.59:80; rewrite ^ https://$host$request_uri? permanent; disable_symlinks if_not_owner from=$root_path; index index.php; set $root_path /bla/bla/example.com.ua; location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/example.com.ua.access.log; error_page 404 = @fallback; } location / { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location @fallback { proxy_pass 95.85.6.59:81; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^.+\.(html|jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|ttf|woff|otf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/access.log; error_page 404 = @fallback; } location ^~ /webstat/ { auth_basic «Restricted area»; auth_basic_user_file /bla/bla/data/etc/802063.passwd; try_files $uri @fallback; } include /bla/bla/etc/nginx.inc; } server { server_name example.com.ua www.example.com.ua; listen 95.85.6.59:443 ssl; disable_symlinks if_not_owner from=$root_path; index index.php; set $root_path /bla/bla/www/example.com.ua; location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/example.com.ua.access.log; error_page 404 = @fallback; } location / { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ { proxy_pass 95.85.6.59:81; proxy_redirect 95.85.6.59:81/ /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location @fallback { proxy_pass 95.85.6.59:81; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; } location ~* ^.+\.(html|jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|ttf|woff|otf)$ { root $root_path; access_log /bla/bla/nginx-logs/ isp; access_log /bla/bla/httpd-logs/access.log; error_page 404 = @fallback; } location ^~ /webstat/ { auth_basic «Restricted area»; auth_basic_user_file /bla/bla/data/etc/802063.passwd; try_files $uri @fallback; } include /usr/local/ispmgr/etc/nginx.inc; ssl_certificate /bla/bla/fhggf.crt; ssl_certificate_key /bla/bla/httpd-cert/fghfd.key; }
конфиг apache
ServerName example.com.ua CustomLog /var/www/httpd-logs/example.com.ua.access.log combined DirectoryIndex index.php DocumentRoot /bla/bla/data/www/example.com.ua ErrorLog /var/www/httpd-logs/example.com.ua.error.log ServerAdmin info@example.com.ua ServerAlias www.example.com.ua SuexecUserGroup domains domains AddHandler fcgid-script .php .php3 .php4 .php5 .phtml ScriptAlias /cgi-bin/ /bla/bla/data/www/example.com.ua/cgi-bin/
.htaccess
RewriteEngine On RewriteRule ^index\.php$ — [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule. /index.php [L] RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI}
Мучаюсь 3 день уже.
Похожие публикации
Использование пространства на хостинге
Установил сервер, нужно привязать домен
посоветуйте анти-ddos сервисы
Сервер 1тб или другое решение задачи
Как удалить иноды на VPS
Нет комментариев