aboutyj
发表于 2017-5-31 16:03:48
本帖最后由 aboutyj 于 2017-5-31 16:05 编辑
如下:但是我想说,谁TM会闲的蛋疼https://domain.com这样去访问啊?这么有空去手输https://?习惯的都是直接在地址栏输domain.com这样吧?然后浏览器自动补齐成http://domain.com然后跳转
vim /your-conf-path/your-conf.conf
server {
listen 80;
server_name domain.com;
return 301 https://www.domain.com$request_uri;
}
server {
listen 80;
server_name www.domain.com;
return 301 https://www.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
ssl_certificate /your-sslca-path/domain.crt;
ssl_certificate_key /your-sslca-path/domain.key;
return 301 https://www.domain.com$request_uri;
}
server {
listen 443 ssl;
server_name www.domain.com;
charset utf-8;
ssl on;
ssl_certificate /your-sslca-path/domain.crt;
ssl_certificate_key /your-sslca-path/domain.key;
ssl_session_timeout60m;
ssl_protocolsSSLv2 SSLv3 TLSv1;
ssl_ciphersALL:!ADH:!EXPOR***56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
location / {
......
}
......
}
菊部紧张
发表于 2017-5-31 16:09:58
我自己用的你看看,我直接lnmp生成的改的
server
{
listen 80;
server_name www.domain.com domain.com;
rewrite ^(.*)$https://www.domain.com/$1 permanent;
}
server
{
#listen 80;
#listen [::]:80;
listen 443;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.domain.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/www.domain.com/root_ca_cert_plus_intermediates;
ssl_session_timeout5m;
server_name www.domain.com domain.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/domain.com;
if ($host = 'domain.com')
{
rewrite ^/(.*)$ https://www.domain.com/$1 permanent;
}
include wordpress.conf;
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log/home/wwwlogs/domain.com.log;
}
朔月
发表于 2017-5-31 16:35:54
server {
listen 80;
listen 443 ssl;
ssl_certificate crt;
ssl_certificate_key key;
add_header Strict-Transport-Security max-age=15768000;
server_name www.domain.com domain.com;
index index.html index.htm index.php;
root /domain.com;
if ($ssl_protocol = "") { return 301 https://$server_name$request_uri; }
直接写在一个server里面。把你的80和443
cjf051
发表于 2017-5-31 17:06:00
aboutyj 发表于 2017-5-31 16:03
如下:但是我想说,谁TM会闲的蛋疼https://domain.com这样去访问啊?这么有空去手输https://?习惯的都是直 ...
可以了,感谢!!
weilai丶
发表于 2017-5-31 18:31:00
朔月 发表于 2017-5-31 16:35
直接写在一个server里面。把你的80和443
大佬,我用你这个可以跳https,不过和楼主情况一样,https好像跳不了!
yipai
发表于 2017-5-31 19:38:10
哪用那么麻烦,直接用dns服务商的301跳转功能 把不带www的跳转到带www的域名上就好
yockii
发表于 2017-6-1 06:30:07
网页文件跳转