@vkrutik

Настройка nginx http to https редирект?

server {
	server_name 123.com www.123.com;
	add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/123.com/*.conf;
	access_log /var/www/httpd-logs/123.com.access.log;
	error_log /var/www/httpd-logs/123.com.error.log notice;
	return 301 https://$host:443$request_uri;
	set $root_path /var/www/www-root/data/www/123.com/public;
	root $root_path;
	listen 123.123.123.123:80 default_server;
	error_page 404 /index.php;
	location / {
		try_files $uri $uri/ /index.php?$query_string;
		}
	
	location ~ \.php$ {
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name;
		fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
		include fastcgi_params;
	}
}


На данный момент у меня такой конфиг, для перенаправления http запросов в https.
Подскажите пожалуйста как его изменить чтобы при запросах на две страницы (на главную и на 123.com/bonus) перенаправления в https не происходило
  • Вопрос задан
  • 107 просмотров
Пригласить эксперта
Ответы на вопрос 1
@dodo512
server {
    listen 123.123.123.123:80 default_server;
    
    server_name 123.com www.123.com;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    charset off;
    index index.php index.html;
    
    set $root_path /var/www/www-root/data/www/123.com/public;
    root $root_path;
    disable_symlinks if_not_owner from=$root_path;

    access_log /var/www/httpd-logs/123.com.access.log;
    error_log /var/www/httpd-logs/123.com.error.log notice;
    
    error_page 404 /index.php;

    location / {
        return 301 https://$host$request_uri;
    }
    
    location ~ ^/(bouns)?$ {
        fastcgi_param SCRIPT_FILENAME $root_path/index.php;
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        include fastcgi_params;
    }
}
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы