2016-08-28 13 views
0

同じnginxサーバー上に無関係な複数のサイトをホストしようとしています。 http.confとhttps.confファイルを編集するにはどうすればよいですか?Nginxサーバー複数のサイトとドメインのリダイレクト(同じポート/別のポート上)

server { 
    listen 2333; 
    server_name port1.example.com; 
    rewrite ^/(.\*) http://port1.example.com/$1 permanent; 
    root /var/www/html; 
    index index.php index.html; 

    # set max upload size 
    client_max_body_size 2G; 
    fastcgi_buffers 64 4K; 

    access_log /var/log/nginx/http_access.log combined; 
    error_log /var/log/nginx/http_error.log; 

    location = /favicon.ico { 
     log_not_found off; 
     access_log off; 
    } 

    location = /robots.txt { 
     allow all; 
     log_not_found off; 
     access_log off; 
    } 

    location ~ \.php$ 
    { 
     try_files  $uri =404; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include  fastcgi_params; 
    } 

    location ~* \.(htaccess|htpasswd) { 
     deny all; 
    } 

    # set long EXPIRES header on static assets 
    location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { 
     expires 30d; 
     access_log off; 
    } 

} 

ORIGINAL https.confという

server { 
    listen 4433 ssl default_server; 
    server_name _; 

    ssl_certificate /etc/nginx/ssl/port2.example.com.crt; 
    ssl_certificate_key /etc/nginx/ssl/port2.example.com.key; 

    root /usr/share/nginx/html; 
    index index.php index.html; 

    # set max upload size 
    client_max_body_size 2G; 
    fastcgi_buffers 64 4K; 

    access_log /var/log/nginx/https_access.log combined; 
    error_log /var/log/nginx/https_error.log; 

    location = /favicon.ico { 
     log_not_found off; 
     access_log off; 
    } 

    location = /robots.txt { 
     allow all; 
     log_not_found off; 
     access_log off; 
    } 

    location ~ \.php$ 
    { 
     try_files  $uri =404; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include  fastcgi_params; 
    } 

    location ~* \.(htaccess|htpasswd) { 
     deny all; 
    } 

    # set long EXPIRES header on static assets 
    location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { 
     expires 30d; 
     access_log off; 
    } 

} 

マイポート4433

ORIGINALのhttp.confは明らかにSSLです。ポート2333port1.example.comとポート4433でのみ動作させるにはどうすればport2.example.comで動作するか2333をSSLでも処理できる方が良いでしょう。

+0

あなたは何をしたいですか?あなたのport1.example.comはすでにポート2333でホストされており、port2.example.comはポート4333でリッスンしているサーバーによって提供されています。しかし、私の関心事はhttpリクエストはポート80でデフォルトで、httpsはポート443で実行されています。ちょうどやりたい? – Satys

+0

@Satysしかし、この設定は機能しません。あなたは編集を助けることができますか? –

+0

確かに、私はあなたの要件とセットアップを完全に理解していません – Satys

答えて

0

ご覧いただきありがとうございます。私はNginxを使用して終了し、それは速く/etc/nginx/confフォルダ内の複数の.confファイルを使用して設定していた。

関連する問題