服务器问答
看了 nginx 的 location 优先匹配不是先精准再普通最后正则么, 不知道为什么我的配置却总是直接下面的返匹配跳转 301, 换成 [ location ~ /.+ ] 也没用。。。 求大佬解答下,这是为什么~~~
server { server_name www.a.com a.com; listen 80 ; access_log /var/log/nginx/access.log; location /.well-known/acme-challenge/ { auth_basic off; allow all; root /usr大带宽服务器/share/nginx/html; try_files $uri =404; break; }
rewrite ^(.*) https://$server_name$1 permanent; }
server { server_name www.a.com a.com; listen 443 ssl http2 ; access_log /var/log/nginx/access.log; ssl_session_timeout 5m; ssl_session_cache shared:SSL:50m; ssl_session_tickets off; ssl_certificate /etc/nginx/certs/www.a.com.crt; ssl_certificate_key /etc/nginx/certs/www.a.com.key; add_header Strict-Transport-Security "max-age=31536000" always;
root /home;
location =/ { try_files '' /index.html; }
location / { return 301 https://2.a.com$request_uri; } }