2016-09-07 10 views
0

現時点では、サーバーブロックで次の設定を使用してHTTPSを強制しています。例外のあるnginxでHTTPSを強制する

if ($scheme != "https") { 
    rewrite^https://www.domain.tld$request_uri? permanent; 
} 

今私は「http://www.domain.tld/some/url」のためにこのルールから1 excaptionを追加するだけの作業設定を把握することはできませんしたいと思います。

答えて

0

ありがとうございました!

if ($request_uri != /some/url1) { 
    set $test A; 
} 
if ($request_uri != /some/url2) { 
    set $test "${test}B"; 
} 
if ($scheme = 'http') { 
    set $test "${test}C"; 
} 
if ($test = ABC) { 
    rewrite^https://www.domain.tld$request_uri? permanent; 
} 
+0

読む[このドキュメント](https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/)あなたは 'if'ブロックを使用して設定ファイルを埋める前に。 –

0

2つのサーバーブロックを使用します.1つは安全な接続用で、もう1つは安全でない接続用です。

server { 
    listen 80; 

    location/{ 
     return 301 https://$host$request_uri; 
    } 
    location /some/url { 
     ... 
    } 
    ... 
    include /path/to/common/config; 
} 

server { 
    listen 443 ssl; 
    ... 
    include /path/to/common/config; 
} 

あなたは別のファイルからの一般的な構成で引っ張ってincludeディレクティブを使用することができます。

関連する問題