docker中nginx反向代理问题

使用运行nginx, docker 11111端口映射nginx的80端口
nginx配置如下

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    server {
      listen 80;
      location /goto/ {
        proxy_pass   https://www.kugou.com/;

      }
    }

}

比如主机Ip: 114.188.16.20

访问: 114.188.16.20:11111/goto
期望的是代理到https://www.kugou.com/,但是每次访问 114.188.16.20:11111/goto 总是会直接定向到114.188.16.20/goto , 变成了默认80,
这该怎么处理

阅读 2.1k
2 个回答

/goto/ 匹配不到 /goto
要用 location /goto

这个不一定是反向代理或者docker配置问题,可能是具体的html代码中的问题。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题