Re: Передресация с http на https://

hitarcher nginx-forum at nginx.us
Tue Dec 30 15:14:52 UTC 2014


вот конфиг, прописал редирект c http://domain.me/manager на
https://domain.me/manager вроде работает, а теперь как прописать редирект
все остальное с https на http, помогите пожалуйста!

server {
        server_name domain.me www.domain.me;
        charset UTF-8;
        disable_symlinks if_not_owner from=$root_path;
        index index.html index.php;
        root $root_path;
        set $root_path /home/domain.me;
        ssi on;
        access_log /home/httpd-logs/domain.me.access.log ;
        error_log /home/httpd-logs/domain.me.error.log notice;
        include /etc/nginx/vhosts-includes/*.conf;

        location ^~ /manager {
          if ($scheme = http) {
                return 301 https://$host$request_uri;
                            }
                    try_files $uri $uri/ @backend;
                                }

        location / {
                location ~*
^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
                        try_files $uri $uri/ @fallback;
                }
                location / {
                        try_files /does_not_exists @fallback;
                }
                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @fallback;
                }
        }
        location @fallback {
                error_log /dev/null crit;
                proxy_pass http://127.0.0.1:8080;
                proxy_redirect http://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;
                proxy_set_header X-Forwarded-Secret GeBJ20wa6DzIiPCK;
                access_log off ;
        }
        listen 123.123.123.123:80;
}

server {
        server_name domain.me www.domain.me;
        charset UTF-8;
        disable_symlinks if_not_owner from=$root_path;
        index index.html index.php;
        root $root_path;
        set $root_path /home/ziranov/data/www/domain.me;
        ssi on;
        access_log /home/httpd-logs/domain.me.access.log ;
        error_log /home/httpd-logs/domain.me.error.log notice;
        include /etc/nginx/vhosts-includes/*.conf;

        location / {
                location ~*
^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
                        try_files $uri $uri/ @fallback;
                }
                location / {
                        try_files /does_not_exists @fallback;

                }
                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @fallback;
                }
        }
        location @fallback {
                error_log /dev/null crit;
                proxy_pass http://127.0.0.1:8080;
                proxy_redirect http://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;
                proxy_set_header X-Forwarded-Secret GeBJ20wa6DzIiPCK;
                access_log off ;
        }
        listen 123.123.123.123:443;
        ssl on;
        ssl_certificate /var/www/httpd-cert/ziranov/domain.me.crt;
        ssl_certificate_key /var/www/httpd-cert/ziranov/domain.me.key;
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?21,255869,255883#msg-255883



Подробная информация о списке рассылки nginx-ru