nginx - 端口转发到另一个容器

时间:2018-04-10 14:39:50

标签: docker nginx nginx-reverse-proxy

我试图使用nginx容器,它将用于将转发通信转发到其他容器,例如Ansible / GIT / Jenkins等....

当使用nci-ansible-ui作为Ansible时,我可以使用外部主机服务器IP http://10.97.98.6:3000(根据说明)访问Ansible UI。然而,当尝试使用nginx移植到此容器时 - 在网页未正确加载时,日志中会出现404和502错误...请注意,在这种情况下,我想使用{{3} }作为URL。请注意,http://10.97.98.6/Master_Ansible是给予容器的docker网络IP ...



server {
    listen       80;
    listen       3000;
    server_name  localhost;

    #charset koi8-r;
    access_log  /var/log/nginx/access.log  main;
    error_log  /var/log/nginx/error.log  warn;

    root /etc/nginx/html;
    index index.html index.php;

    #charset koi8-r;

   location / {
    root /etc/nginx/html;
        try_files $uri /$uri $uri/ =404;
   }

    location /Master_Ansible {
        proxy_pass         http://172.18.0.5:3000;
        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 http;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout      150;
        proxy_send_timeout         100;
        proxy_read_timeout         100;
        proxy_buffer_size          8k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }

}




对此有何想法?

0 个答案:

没有答案