全球主机交流论坛
标题:
Nginx访问http域名跳转到https怎么设置?
[打印本页]
作者:
一手好湿
时间:
2011-11-25 18:57
标题:
Nginx访问http域名跳转到https怎么设置?
新建了一个虚拟主机,虚拟主机的配置文件如下,网址替换了,怕怕
求访问xxx.com自动跳转到
https://xxx.com
同时访问xxx.com/1.php能自动跳转到
https://xxx.com/1.php
感激不尽
server
{
listen 80;
server_name xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/xxx.com;
listen 443;
server_name www.xxx.com xxx.com;
index index.html index.htm index.php;
error_page 404 403 http://xxx.com;
ssl on;
ssl_certificate /root/vision_im.crt;
ssl_certificate_key /root/server.key;
include wordpress.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
log_format xxx.com '$remote_addr - $remote_user [$time_local] $request '
'$status $body_bytes_sent $http_referer '
'$http_user_agent $http_x_forwarded_for';
access_log /home/wwwlogs/xxx.com.log xxx.com;
}
复制代码
作者:
ixbear
时间:
2011-11-25 19:00
强制开启SSL(强制http转向https)
server
{
listen 80;
server_name 域名;
rewrite ^/(.*) https://域名/$1 permanent;
}
server
{
listen 443;
server_name 域名;
index index.html index.htm index.php;
root /home/wwwroot;
ssl on;
ssl_certificate /home/wwwroot/xxx.crt;
ssl_certificate_key /home/wwwroot/xxx.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPOR***56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param HTTPS on;
}
复制代码
加分,谢谢
作者:
onesz
时间:
2011-11-25 19:02
坐等技术帝
欢迎光临 全球主机交流论坛 (https://sunk.eu.org/)
Powered by Discuz! X3.4