NGINX reverse proxy for Jenkins on a Windows 10

2019-07-28 22:52发布

问题:

So I have looked at all the tutorials that I could found on this topic, and nothing worked. I have a JENKINS instance on a windows 10 pro, and a centos with nginx. I want to use the NGINX as reverse proxy for Jenkins, to have https and make it accessible from internet. My current configuration is:

    server {
listen 80;
listen [::]:80;
server_name build.test.com;

access_log  /var/log/nginx/log/build.test.com.access.log  main;
error_log  /var/log/nginx/log/build.test.com.error.log;

    location ^~ /jenkins/ {

            proxy_pass http://192.X.X.X:8080/;
            proxy_redirect      http://192.X.X.X:8080 http://build.test.com;

            sendfile off;

            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;
            proxy_max_temp_file_size 0;

            #this is the maximum upload size
            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_temp_file_write_size 64k;

            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            proxy_buffering off; # Required for HTTP-based CLI to work over SSL
      }
    }

(I replaced the real url and IPs.) But this gave me a 502 Bad Gateway. With the following error: connect() to 192.X.X.X:8080 failed (13: Permission denied) while connecting to upstream, client: 192.168.5.254, server: build.test.com, request: "GET /jenkins HTTP/1.1", upstream: "http://192.X.X.X:8080/", host: "build.test.com"

But on my local network when I try to access the server with the http://192.X.X.X:8080/ url, it works fine. Any idea ?

Thanks

回答1:

Doing a little bit of research indicates that this is most likely an issue within CentOS, and more specifically, SELinux. SELinux could be causing the problem in any number of locations; however, this is probably going to be a good jumping off point: https://stackoverflow.com/a/24830777/8680186

Check the SELinux logs to figure out why it's throwing a hissy fit if the above doesn't help.