首页 新闻 会员 周边 捐助

windows nginx 地址栏变成了upstream的值

0
[已解决问题] 解决于 2018-11-27 09:48

nginx配置如下

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    upstream bbing{
    server 39.1.99.73:8022;
    server 47.1.12.138:8010;
    }

    server {
        listen       8015;
        server_name  api.cobblcloud.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        proxy_pass http://bbing;
            root   html;
            index  index.html index.htm;
        }
 

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

打开可以

 

 

但在地址栏输入http://api.cobblloud.com:8015/swagger跳转到指定页面后,地址栏变成了http://bbing:8022/swagger/ui/index。  bbing是upstream的值

 

chester·chen的主页 chester·chen | 小虾三级 | 园豆:507
提问于:2018-06-28 17:48
< >
分享
最佳答案
0

建议通过 nginx -t -c /etc/nginx/nginx.conf 命令检查一下配置

奖励园豆:5
dudu | 高人七级 |园豆:30778 | 2018-06-28 18:24

 我访问监听端口的时候,39.107.99.73:8015/swagger,地址栏就编程http://39.107.99.73:8010/swagger了,端口号是 upstream中的一台服务其的端口

    upstream bbing{
    server 39.107.99.73:8022;
    server 47.104.12.138:8010;
    }

    server {
        listen       8015;
        server_name  39.107.99.73;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        proxy_pass http://bbing;
            root   html;
            index  index.html index.htm;
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

 

 

chester·chen | 园豆:507 (小虾三级) | 2018-06-29 14:00

 访问接口是没问题的,只有访问swgger时,有这个问题

chester·chen | 园豆:507 (小虾三级) | 2018-06-29 14:13

您试一下http://39.107.99.73:8015

再试一下http://39.107.99.73:8015/swagger

chester·chen | 园豆:507 (小虾三级) | 2018-06-29 14:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册