今天要来问下Nginx的配置问题...
By
后宫学长
at 2017-04-20 • 0人收藏 • 8666人看过
我是Nginx+Apache。
现在的问题是:手机版的问题。
PC直接访问PC版http地址,Nginx正常跳转https地址,正常访问。
PC直接访问手机版http地址,Nginx跳转到PC版https地址。
PC直接访问手机版https地址,Nginx正常访问。
但是用手机浏览器(安卓UA)却无法访问。
具体表现为URL一直在http和https中重复301,然后提示无法访问。
有时候也会正常返回手机版URL,但是貌似还是存在重复301,依旧无法访问。
有时候直接输入手机版地址可以访问。



请问这是哪里出了问题呢?
今天才发现问题。
Nginx配置了http跳转https。(肯定是这里的锅!)
Apache的.htaccess中的跳转已注释。
server {
listen 80;
listen 443 ssl http2;
ssl_certificate /usr/local/nginx/conf/ssl/tucao.moe.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/tucao.moe.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name tucao.moe i.tucao.moe m.tucao.moe;
access_log /data/wwwlogs/tucao.moe_nginx.log combined;
index index.html index.htm index.php;
root /data/wwwroot/tucao.moe;
if ($ssl_protocol = "") { return 301 https://$server_name$request_uri; }
location / {
try_files $uri @apache;
}
location @apache {
proxy_pass http://127.0.0.1:88;
include proxy.conf;
}
location ~ .*\.(php|php5|cgi|pl)?$ {
proxy_pass http://127.0.0.1:88;
include proxy.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ /\.ht {
deny all;
}
}#SSL
#RewriteCond %{HTTP_HOST} ^tucao.moe$ [NC]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://tucao.moe/$1 [L,R=301]
#RewriteCond %{HTTP_HOST} ^m.tucao.moe$ [NC]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://m.tucao.moe/$1 [L,R=301]
31 个回复 | 最后更新于 2017-04-24
登录后方可回帖





还是多看文档吧。
粤公网安备 44030602003677号
@lincanbin :额...dalao请教下问题,谢谢。