请问怎么让所有的http自动变成https
请问怎么让所有的http自动变成https 配置文件里用301 跳转 https://lnmp.org/faq/lnmp-nginx-301-rewrite.html回复 3# 的帖子
收到。。上次就看你给别人这个教程。。我试一试。回复 3# 的帖子
我按照那个方法。。所有位置都弄了。不能301重定向server
{
listen 80;
#listen [::]:80;
server_name www.7shb.com 7shb.com ;
index index.html index.htm index.php default.html default.htm default.php;
root/7shb;
include other.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log/home/wwwlogs/www.7shb.com.log;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.7shb.com wwww.7shb.com 7shb.com;
index index.html index.htm index.php default.html default.htm default.php;
root/7shb;
ssl on;
ssl_certificate /home/wwwroot/www.7shb.com/apache/www.7shb.com.crt;
ssl_certificate_key /home/wwwroot/www.7shb.com/apache/www.7shb.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EEC3DES:RSA+3DES:!MD5";这里隐藏一下。
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
include other.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log/home/wwwlogs/www.7shb.com.log;
}
server {
listen 80;
server_name www.7shb.com;
return 301 https://www.7shb.com$request_uri;
}
页:
[1]