2015-06-02 167 views
1

我已经部署了一个带有ISPConfig和Nginx的CentOS服务器。Ispconfig nginx重定向到https

另外我能够配置Nginx的,手动(通过编辑/etc/nginx/sites-available/mysite.com.vhost),HTTP请求重定向到https:

server { 
    listen 80; 
    server_name mysite.com; 
    return   301 https://$server_name$request_uri; 
} 

server { 
    listen 443 ssl; 
    .. 
} 

正如我编辑的每次我用ISPConfig更改设置时,我的虚拟主机文件被覆盖,我失去了我的重定向技巧。

您是否知道使用ISPConfig面板配置上述重定向的方法,而不是手动编辑nginx文件?

非常感谢。

回答

0

在最新版本的ISPConfig上,您可以简单地选择网站使用SSL(并且这意味着HTTPS以及SPDY或HTTP/2),并具有额外的复选框将所有HTTP请求永久重定向到HTTPS, ISPConfig将自动正确生成虚拟主机文件。

对于completude的缘故,这是ISPConfig补充说:

server { 
     listen *:80; 

     listen *:443 ssl; 
       ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
     ssl_certificate /var/www/clients/clientX/webY/ssl/your.web.site.crt; 
     ssl_certificate_key /var/www/clients/clientX/webY/ssl/your.web.site.key; 

     server_name your.web.site www.your.web.site; 

     root /var/www/your.web.site/web/; 

     if ($http_host = "www.your.web.site") { 
      rewrite^$scheme://your.web.site$request_uri? permanent; 
     } 
     if ($scheme != "https") { 
      rewrite^https://$http_host$request_uri? permanent; 
     } 


     index index.html index.htm index.php index.cgi index.pl index.xhtml; 
1

我已经配置了重定向为接受的答案建议。

另外我还包含一个外部配置,所以我把所有的手动配置。

在我们ISPConfig的版本,我这样做:

if ($scheme != "https") { 
    rewrite^https://$http_host$request_uri? permanent; 
} 

include /etc/nginx/sites-available/my-own-config.conf; 

这样,ISPConfig不会打破我们的CONFIGS。