通过外网端口映射访问出错


#1
 server {
        listen 80;
        server_name  域名;
        rewrite ^ https://域名:443$request_uri? permanent;
        server_tokens off;
    }
    
    server {
        listen 443;
        server_name ;
        ssl on;
        ssl_certificate   证书位置;
        ssl_certificate_key  证书秘钥位置;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
	proxy_set_header X-Forwarded-For $remote_addr;


	add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        server_tokens off;


	location / {
		proxy_pass         http://seafile服务器地址;
		proxy_set_header   Host $host;
		proxy_set_header   X-Real-IP $remote_addr;
		proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header   X-Forwarded-Host $server_name;
		proxy_set_header   X-Forwarded-Proto https;

		access_log      /var/log/nginx/seahub.access.log;
		error_log       /var/log/nginx/seahub.error.log;

		proxy_read_timeout  1200s;

		client_max_body_size 0;
	}

    	location /seafhttp {
        	rewrite ^/seafhttp(.*)$ $1 break;
        	proxy_pass http://seafile服务器地址;
        	client_max_body_size 0;
       		proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        	proxy_connect_timeout  36000s;
        	proxy_read_timeout  36000s;
        	proxy_send_timeout  36000s;
        	send_timeout  36000s;
    	}
	location /media {
        root /var/www/cloud;
    	}
    }

}

上面贴出的是配置文件
seafile跑在一台win服务器上,一切默认
ngnix做反代
内部dns解析域名至反代服务器,测试一切访问正常,http请求自动跳转至https
外部是端口映射,映射了7320做http口,但是跳转失败,会跳转至https://域名7320
但是另外的静态站点(同nginx同配置)在外部的7320却跳转正常
请问有巨佬能给萌新提供帮助吗QWQ


#2

具体一点,跳转失败与成功的,分别在哪些网段?是在服务器所在的局域网还是外网?


#3

首先,所有服务器均在内网同一网段
然后,我的博客,一个静态页面的服务器,采用同样配置,100%成功跳转
再然后,seafile服务器在任意设备上第一次访问http://域名:7320会成功跳转至https://域名
但是之后都会失败,因为会直接访问https://域名:7320


#4

人工置顶求助QWQ~~~~