2014-11-13 6 views
0

에 나는이에 대한 몇 가지 대답을 읽어 http://localhost재 작성에 http https를 Nginx에

https://localhost에 다시하려고하고, 난 내 로컬 서버에 그것을 시도 할 때 작동합니다.

server { 
    listen 80; 

    rewrite ^(.*) https://$server_name$request_uri permanent; 
    [...] 
} 

을하지만이 같은 IP와 함께 다른 컴퓨터에서 올 때 : 나는이 라인을 함께 할 xxx.xxx.xxx.xxx:8086https://localhost 날 리디렉션 나는 그것을 원하지 않는다.

그래서, 나는이 같은 시도 :

server { 
    listen 80; 

    rewrite ^(.*) https://$server_name$request_uri permanent; 
    [...] 
} 

또 다른 문제 : 8086 : 내 않고 https://xxx.xxx.xxx.xxx 날 리디렉션! 그게 내가 원하는 것도 아니에요 ...

누구나 나를위한 해결책이 있습니까?

고맙습니다.

Maxime.

편집 :

내 설정 : 내 응원의 설정에

server { 


    listen 80; 


    #rewrite ^(.*) https://$host:8086$request_uri permanent; 

    root /var/www; 
    rewrite^https://$server_name$request_uri permanent; 
    index index.php index.html index.htm; 

    location/{ 
     try_files $uri $uri/ /index.html; 
    } 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name; 
     include fastcgi_params; 
    } 
} 

server { 


    listen 443 ssl; 
    server_name localhost; 

    ssl on; 
    ssl_certificate  ./cert.crt; 
    ssl_certificate_key ./cert.key; 

    ssl_session_cache shared:SSL:1m; 
    ssl_session_timeout 5m; 

    ssl_ciphers HIGH:!aNULL:!MD5; 
    ssl_prefer_server_ciphers on; 

    root /var/www; 
    index index.php index.html index.htm; 

    location/{ 
     try_files $uri $uri/ /index.html; 
    } 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name; 
     include fastcgi_params; 
    } 
} 

,이 서버의 포트 리디렉션이 동일한 포트에서 HTTPS에 HTTP를 리디렉션 할 수 없습니다 8086

답변

0

입니다 . 다른 포트에서 수신 대기해야합니다. 그렇지 않으면 재 작성 루프가 생깁니다. 그래서 예를 들면

:

그냥 당신이 원하는 것을 명확히하기 :

 World 
      | 
      | 
http://localhost:8086 
      | 
      | 
https://localhost:8086 
      | 
      | 
https://localhost:443 

는 당신을위한 proxy_pass를 사용해야합니다 전체 구성


편집

server { 
    listen 80; 
    server_name example.com; 
    root /nowhere; # this doesn't have to be a valid path since we are redirecting, you don't have to change it. 
    rewrite^https://$server_name$request_uri permanent; 
} 

server { 
    listen 443 ssl; 
    server_name example.com; 
    root /some/valid/directory; 

    ssl on; 
} 
이. 또한 nginx를 오류 코드 497는 도움이 될 수 있습니다 : http://nginx.org/en/docs/http/ngx_http_ssl_module.html#errors

이 구성에 다음과 같은 서버 지시문을 추가 ...

server { 
    listen 8086 ssl; 
    ssl on; 
    ssl_certificate  ./cert.crt; 
    ssl_certificate_key ./cert.key; 

    ssl_session_cache shared:SSL:1m; 
    ssl_session_timeout 5m; 

    ssl_ciphers HIGH:!aNULL:!MD5; 
    ssl_prefer_server_ciphers on; 

    error_page 497 https://$host:$server_port$request_uri; 
    location/{ 
     proxy_pass https://localhost:443; 
     proxy_redirect off; 
     proxy_set_header Host $host:$server_port; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Ssl on; 
    } 
} 
+0

을 내가 그렇게 이미하고 있습니다. 하지만 그것은 잘못 리디렉션됩니다 :/the : 8086 여기 다시는 없습니다! – Maxouhell

+0

@maxouhell, : 8086은 전혀 리디렉션되지 않아야합니다. 포트 80 만 ... 설정에서 복사하여 붙여 넣을 수 있습니까? – Si289

+0

나는 내 첫 게시물에 그것을 해왔다. 도와 줘서 고마워. – Maxouhell

관련 문제