Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

Nginx 反向代理 + 重定向问题

现在的情况是:我有一个域名 https://a.bc.com 用了 Nginx 反向代理到本地的 Docker,容器里用的端口是 8888,现在刚打开页面是好的,但是一刷新就变成了 https://a.bc.com:8888 求教配置出了什么问题,一下是我的配置:

server {
    server_tokens off;
    gzip on; 
    gzip_types      application/json application/javascript text/css;
    gzip_proxied    no-cache no-store private expired auth;
    gzip_min_length 1000;
    client_max_body_size 500m;
        
    server_name  a.bc.com;
    
    location / {
        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-Proto https;
        proxy_pass http://localhost:8888/;
        proxy_redirect http:// https://;
    }
   
    listen 443 ssl;
    ssl_certificate .....
    ssl_certificate_key ......
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIa.bc.comGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
}

server {
      if ($host = a.bc.com){
          return 301 https://$host$request_uri;
      }
      server_name  a.bc.com;
      listen 80;
      return 404; # managed by Certbot
    
 }


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...