全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
楼主: akige

http强制跳到 https带www nginx配置问题,大佬看下哪的问题

[复制链接]
发表于 2018-5-1 22:07:12 | 显示全部楼层
akige 发表于 2018-5-1 21:56
报错:

Firefox has detected that the server is redirecting the request for this address in a wa ...




  1. server {
  2.         listen 80 ;
  3.        
  4.         listen 443 ssl http2;
  5.         ssl on;
  6.         ssl_certificate /usr/local/nginx/conf/ssl/www.mysite.com/fullchain.cer;
  7.         ssl_certificate_key /usr/local/nginx/conf/ssl/www.mysite.com/www.mysite.com.key;
  8.         ssl_session_timeout 5m;
  9.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  10.         ssl_prefer_server_ciphers on;
  11.         ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
  12.         ssl_session_cache builtin:1000 shared:SSL:10m;
  13.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  14.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
  15.        
  16.         server_name www.mysite.com mysite.com;
  17.        
  18.         if ($http_host != $server_name) {
  19.                 return 301 https://$server_name$request_uri;
  20.         }
  21.         if ($scheme = http) {
  22.                 return 301 https://$server_name$request_uri;
  23.         }


  24.         index index.html index.htm index.php default.html default.htm default.php;
  25.         root  /home/wwwroot/www.mysite.com;
  26.        
  27.         include rewrite/laravel.conf;
  28.                
  29.         include enable-php-pathinfo.conf;

  30.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  31.         {
  32.                 expires      30d;
  33.         }

  34.         location ~ .*\.(js|css)?$
  35.         {
  36.                 expires      12h;
  37.         }

  38.         location ~ /.well-known {
  39.                 allow all;
  40.         }

  41.         location ~ /\.
  42.         {
  43.                 deny all;
  44.         }

  45.         access_log  /home/wwwlogs/www.mysite.com.log;
  46. }
复制代码
发表于 2018-5-1 22:11:40 | 显示全部楼层
server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name www.baidu.com baidu.com;
  if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
  if ($host != www.baidu.com) {  return 301 $scheme://www.baidu.com$request_uri;

这样写一个server块就够了 看着舒服
发表于 2018-5-1 22:12:36 来自手机 | 显示全部楼层
为何不试试meta跳转?
 楼主| 发表于 2018-5-1 22:17:43 | 显示全部楼层
本帖最后由 akige 于 2018-5-1 22:19 编辑


大佬 按照你的测试  还是不行:

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

nginx -s reload 有做
 楼主| 发表于 2018-5-1 22:21:11 | 显示全部楼层
ponyxx 发表于 2018-5-1 22:12
为何不试试meta跳转?

想在服务端做
 楼主| 发表于 2018-5-1 22:31:17 | 显示全部楼层
陈道临 发表于 2018-5-1 22:11
server {
  listen 80;
  listen [::]:80;

还是有问题。。大佬你测试过吗?
 楼主| 发表于 2018-5-1 22:32:47 | 显示全部楼层
陈道临 发表于 2018-5-1 22:11
server {
  listen 80;
  listen [::]:80;

能贴一个完整的。你测试过的吗?我看着你配的貌似是那个逻辑,但是测试确实不行。跟我之前写的情况有点类似。
发表于 2018-5-1 22:34:09 | 显示全部楼层
akige 发表于 2018-5-1 22:32
能贴一个完整的。你测试过的吗?我看着你配的貌似是那个逻辑,但是测试确实不行。跟我之前写的情况有点类 ...

发个url来看看吧  
 楼主| 发表于 2018-5-1 22:45:16 | 显示全部楼层
陈道临 发表于 2018-5-1 22:11
server {
  listen 80;
  listen [::]:80;

  1. server
  2.         {
  3.                 listen 80;
  4.                 listen [::]:80;
  5.                 listen 443 ssl http2;
  6.                 listen [::]:443 ssl http2;
  7.                 server_name www.mysite.com mysite.com;
  8.                
  9.                 if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
  10.                 if ($host != www.mysite.com) {  return 301 $scheme://www.mysite.com$request_uri;}
  11.                
  12.                
  13.                
  14.         ssl on;
  15.         ssl_certificate /usr/local/nginx/conf/ssl/www.mysite.com/fullchain.cer;
  16.         ssl_certificate_key /usr/local/nginx/conf/ssl/www.mysite.com/www.mysite.com.key;
  17.         ssl_session_timeout 5m;
  18.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  19.         ssl_prefer_server_ciphers on;
  20.         ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
  21.         ssl_session_cache builtin:1000 shared:SSL:10m;
  22.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  23.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
  24.         
  25.         
  26.         index index.html index.htm index.php default.html default.htm default.php;
  27.                
  28.         root  /home/wwwroot/www.mysite.com;
  29.         
  30.         include rewrite/laravel.conf;
  31.                
  32.         include enable-php-pathinfo.conf;

  33.                
  34.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  35.         {
  36.                 expires      30d;
  37.         }

  38.         location ~ .*\.(js|css)?$
  39.         {
  40.                 expires      12h;
  41.         }

  42.         location ~ /.well-known {
  43.                 allow all;
  44.         }

  45.         location ~ /\.
  46.         {
  47.                 deny all;
  48.         }

  49.         access_log  /home/wwwlogs/www.mysite.com.log;
  50.         }
复制代码


大佬 按照你这个配置 真的有问题 。你去测试下。我看着语法也没问题。就是不行。。。。
发表于 2018-5-1 22:52:04 | 显示全部楼层
akige 发表于 2018-5-1 22:45
大佬 按照你这个配置 真的有问题 。你去测试下。我看着语法也没问题。就是不行。。。。 ...


怎么感觉是你firefox的缓存 ,换个浏览器或者硬清空缓存试试看
还有 firefox的跳转记录也可以发上来
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-20 08:11 , Processed in 0.071707 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表