我已经部署了一个CentOS服务器,它使用ISPConfig和Nginx。
此外,我还能够手动配置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更改一个设置时,我的vhost文件就会被覆盖,并且我失去了重定向的技巧。
您知道如何使用ISPConfig面板来配置上述重定向,而不是手动编辑nginx文件吗?
感谢报仇。
发布于 2016-06-07 22:45:15
在最新版本的ISPConfig上,您可以简单地选择要使用SSL的网站(这意味着HTTPS,也可以选择SPDY或HTTP/2),还有一个额外的复选框可以永久地将所有HTTP请求重定向到HTTPS,ISPConfig将自动正确地生成vhost文件。
为了完整起见,这就是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;发布于 2016-08-26 12:18:40
我已经按照公认的答案配置了重定向。
此外,我还包括了一个外部配置,所以我把所有的手动配置。
在我们版本的ISPConfig中,我这样做了:
if ($scheme != "https") {
rewrite ^ https://$http_host$request_uri? permanent;
}
include /etc/nginx/sites-available/my-own-config.conf;这样,ISPConfig就不会破坏我们的信任。
https://stackoverflow.com/questions/30607612
复制相似问题