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

Juriy Strashnov juriy.foboss at gmail.com
Tue Dec 30 15:26:01 UTC 2014


Отчего же, ответил именно на поставленный вопрос. Да, правда вижу опечатку
в примере, там вот так должно быть:

server {
    listen       192.168.7.1:80 <http://192.168.7.1/>        default_server;
    listen       192.168.7.2:443 ssl default_server;
    server_name  example.com;

# HTTP -> HTTPS
 location /manager {
        if ($scheme = http) { rewrite ^(.*) https://$server_name$1
permanent; }
        <...>
    }

# HTTPS -> HTTP
 location / {
        if ($scheme = https) { rewrite ^(.*) http://$server_name$1
permanent; }
        <...>
    }

On Tue, Dec 30, 2014 at 6:14 PM, hitarcher <nginx-forum at nginx.us> wrote:

> вот конфиг, прописал редирект 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 mailing list
> nginx-ru at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>



-- 
Best regards, Juriy Strashnov

Mob. +7 (953) 742-1550
E-mail: j.strashnov at me.com

Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-ru/attachments/20141230/b1d62119/attachment-0001.html>


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