2010-11-24 6 views
0

開発サーバーでlighttpdをnginxに置き換えます。私はそれをPHPとSSLで動作させましたが、単純な書き直しをする必要があります。私は私が使用していますnginxはミステリーを書き換えます - ホスト名を複製してhttpsを失う

http[s]://dev.foo.com/signup/index.php?attcode=123456 

ルールに

http[s]://dev.foo.com/signup/123456 

からURLを書き直す必要がある:私は内側にそれを入れて、それを周りに移動し、この上の多数のバリエーションを試してみました

rewrite ^/signup/([0-9]+)$ /signup/index.php?attycode=$1 last; 

ロケーションブロック。 URLが次のURLに書き換えられます:

ホスト名が挿入され、常にhttpsが消えてhttpになります。

私のnginx.comサーバーのセクションは以下の通りです。私はnginxのドキュメントを読んで再読み込みしていましたが、nginxのメーリングリストを検索しましたが、私が試したことは何もこの問題を解決していません。

Ubuntu 8.0.4 LTSが重要な場合。

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


server { 
    listen  80; 
    listen  443 default ssl; 
    server_name dev.foo.com dev.bar.com localhost; 
    root  /var/www/foo; 
    index  index.php index.html; 
    # ssl cert stuff omitted 
    charset utf-8; 
    access_log /var/log/www/dev.access.log main; 

    location ~ /\. { 
     deny all; 
    } 

    location ~* ^.+\.(inc|tpl|sql|ini|bak|sh|cgi)$ { 
     deny all; 
    } 

    location ~* ^/(scripts|tmp|sql)/ { 
     deny all; 
    } 

    rewrite ^/robots.txt$   /robots_nocrawl.txt break; 
    rewrite ^/signup/([0-9]+)$ /signup/index.php?attycode=$1 last; 

    location/{ 
     try_files $uri $uri/ /error_404.php; 
    } 

    location ~ \.php$ { 
     fastcgi_pass localhost:51115; 
     fastcgi_index index.php; 
     fastcgi_intercept_errors on; 
     include fastcgi_params; 
     fastcgi_param SERVER_NAME  $http_host; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 

    error_page 404    /error_404.php; 
} 

答えて

0

同じサーバブロックでHTTPとHTTPSを入れないでください。 HTTPとHTTPSの2つのほぼ同一のサーバーブロックに分けます。さもなければ、あなたはあらゆる種類のNginx内部を混乱させます。

+0

nginxのドキュメントは、少なくとも、単一のサーバーブロックでhttpとhttpsを組み合わせても問題ないことを意味します。 http://www.nginx.org/en/docs/http/configuring_https_servers.html – gregjor

+0

シンプルにするためにlistenパラメータと追加のサーバー名を取り出しました。書き換えはまだ動作しておらず、まだhttpsからhttpに切り替わります。 – gregjor

関連する問題