Все сервисы Хабра
Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Закрыть
Задать вопрос
shevlyakovn
0
вклад
3
вопроса
2
ответа
0%
решений
Комментарии
Информация
Ответы
Вопросы
Комментарии
Подписки
Нравится
Достижения
Настройка редиректа на https nginx?
shevlyakovn
@shevlyakovn
Автор вопроса
Много конфигов, наследение isp manager. Итоговое решение, которое работает.
server {
listen 99.99.999.999:80;
server_name test.ru www.test.ru;
charset UTF-8;
disable_symlinks if_not_owner from=$root_path;
index index.html index.php;
root $root_path;
set $root_path /var/www/test/data/www/test.ru;
access_log /var/www/httpd-logs/test.access.log ;
error_log /var/www/httpd-logs/test.error.log notice;
include /etc/nginx/vhosts-includes/*.conf;
ssi on;
location /test/ {
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $uri/ @fallback;
expires 3d;
}
location /test/ {
try_files /does_not_exists @fallback;
}
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
}
location / {
return 301
https://$host$request_uri;
}
location @fallback {
proxy_pass
http://127.0.0.1:8080;
proxy_redirect
127.0.0.1:8080
/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
access_log off ;
}
}
Написано
более трёх лет назад
Войдите на сайт
Чтобы задать вопрос и получить на него квалифицированный ответ.
Войти через центр авторизации
Закрыть
Реклама
server {
listen 99.99.999.999:80;
server_name test.ru www.test.ru;
charset UTF-8;
disable_symlinks if_not_owner from=$root_path;
index index.html index.php;
root $root_path;
set $root_path /var/www/test/data/www/test.ru;
access_log /var/www/httpd-logs/test.access.log ;
error_log /var/www/httpd-logs/test.error.log notice;
include /etc/nginx/vhosts-includes/*.conf;
ssi on;
location /test/ {
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $uri/ @fallback;
expires 3d;
}
location /test/ {
try_files /does_not_exists @fallback;
}
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
}
location / {
return 301 https://$host$request_uri;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect 127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
access_log off ;
}
}