全球主机交流论坛
标题:
nginx 跳转 https问题 (感谢各位回答!)
[打印本页]
作者:
3721
时间:
2021-1-19 13:44
标题:
nginx 跳转 https问题 (感谢各位回答!)
本帖最后由 3721 于 2021-1-19 14:16 编辑
感谢回答!已解决 方案如下:
#访问http 跳转http
server{
listen 80;
server_name 9i3.cn;
rewrite ^/(.*)$ https://9i3.cn:443/$1 permanent;
}
#www跳转不带www
server {
listen 80;
server_name www.9i3.cn;
return 301 https://9i3.cn$request_uri;
}
复制代码
今天发现百度收录文章 收录了我 不带https 的 我奇怪了 我设置https 还认证https
但是怎么还是 收录http 查看一番 竟然不跳转
访问 : http://9i3.cn/interesting/327.html
竟然 不跳转 为 https://9i3.cn/interesting/327.html
试了其他文章 奇怪了 一样 最近换面板安装的 出现这个问题 。。 问下该怎么修改
访问 : http://9i3.cn/interesting/327.html
跳转为 : https://9i3.cn/interesting/327.html
以下为nginx配置
server {
listen 80;
listen 443 ssl;
root /wwwroot/typecho;
server_name 9i3.cn www.9i3.cn;
#日志文件路径,请不要随意更改,否则将导致面板无法获取到网站日志
error_log "/var/hwsmaster/wwwlogs/9i3.cn_FaCq-error.log";
access_log "/var/hwsmaster/wwwlogs/9i3.cn_FaCq-access.log";
limit_rate 0k;
#伪静态规则,如果删除,则面板设置的伪静态将失效
include /wwwroot/typecho/.htaccess;
#黑名单模式(允许所有,拒绝以下)
deny 54.255.93.11;
deny 18.163.128.157;
deny 113.0.161.50;
deny 13.114.87.202;
deny 45.10.1.85;
deny 107.173.149.117;
allow all;
#DENY FILES
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#STATIC
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
access_log /dev/null;
}
#301重定向
if ($host ~ '^www.9i3.cn'){
return 301 https://9i3.cn$request_uri;
}
#SSL
ssl_certificate /var/hwsmaster/ssl/9i3.cn_wOsEx3QY.pem;
ssl_certificate_key /var/hwsmaster/ssl/9i3.cn_wOsEx3QY.key;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
#PHP
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-7.3.14-default.sock;
fastcgi_index index.php;
include fastcgi.conf;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
error_page 404 /404.html;
index index.php default.php index.html index.htm default.html default.htm start.html;
}
复制代码
作者:
MiaoSir
时间:
2021-1-19 13:56
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
复制代码
作者:
allnetstore
时间:
2021-1-19 13:57
if ($host ~ '^www.9i3.cn'){
复制代码
访问 : http://9i3.cn/interesting/327.html
竟然 不跳转 为 https://9i3.cn/interesting/327.html
你这个元老怎么水出来的
作者:
red233
时间:
2021-1-19 14:01
提示:
作者被禁止或删除 内容自动屏蔽
作者:
yemingtu
时间:
2021-1-19 14:01
server {
listen 80;
server_name .example.com;
location / {
return 301 https://example.com$request_uri;
}
}
复制代码
http要单独配
https 配置到另一个 server 段
作者:
luys
时间:
2021-1-19 14:02
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
复制代码
作者:
citywar
时间:
2021-1-19 14:07
安装一个宝塔 设置一下看他们怎么写的
作者:
yemingtu
时间:
2021-1-19 14:12
风怒了,编辑掉
作者:
3333
时间:
2021-1-19 14:13
提示:
作者被禁止或删除 内容自动屏蔽
作者:
dbug
时间:
2021-1-19 14:47
你的北岸为啥从2开始的
欢迎光临 全球主机交流论坛 (https://sunk.eu.org/)
Powered by Discuz! X3.4