2014-01-21 56 views
0

我的品牌新的Nginx和我已經設置了新鮮與Ajenti在端口8000的Nginx的conf文件:從HTTP子域重定向到HTTPS端口

我看Ajenti有一個子點安裝的是HTTPS,但不在網站上的任何其他地方使用HTTPS。因此,所有這些事情發生:

http { 
    index index.html; 

    ssl_certificate  common.crt; 
    ssl_certificate_key common.key; 

    server { 
     listen 80; 
     server_name www.domain1.co.uk; 
     access_log logs/domain1.access.log main; 

     root /var/www/domain1.co.uk/htdocs; 
    } 
    server { 
     listen 80; 
     server_name sub.domain1.co.uk; 

     location/{ 
      proxy_pass https://127.0.0.1:8000/; 
      proxy_set_header Host $host; 
      proxy_buffering off; 
     } 
    } 
} 

如何爲期不遠是我:

http://domain1.co.uk 

http://sub.domain1.co.uk -> https://sub.domain1.co.uk 

https://sub.domain1.co.uk -> https://domain1.co.uk:8000 

我已經儘可能得到?

在此先感謝

馬赫

+0

沒有它,你期望它做什麼? –

回答

1

如果我理解正確的,這將是:

http { 
    index index.html; 

    ssl_certificate  common.crt; 
    ssl_certificate_key common.key; 

    # Redirect http://sub.domain1.co.uk to https://sub.domain1.co.uk 
    server { 
     listen 80; 
     server_name sub.domain1.co.uk; 

     return 301 https://sub.domain1.co.uk; 
    } 
    # Proxy pass https://sub.domain1.co.uk to http://127.0.0.1:8000/ 
    server { 
     listen 443; 
     server_name https://sub.domain1.co.uk; 
     location/{ 
      proxy_pass http://127.0.0.1:8000/; 
      proxy_set_header Host $host; 
      proxy_buffering off; 
     } 
    } 
    # http://domain1.co.uk & www.domain1.co.uk 
    server { 
     listen 80; 
     server_name domain1.co.uk 
        www.domain1.co.uk; 
     access_log logs/domain1.access.log main; 

     root /var/www/domain1.co.uk/htdocs; 
    }   
}