RUDE

502 Плохой шлюз для Jenkins с nginx

У меня есть VPS с nginx. gitlab, phpmyadmin уже работает с certbots https. Теперь я хочу добавить Дженкинса. Я изменил его порт на 8090, чтобы он не совпадал с портом gitlabs 8080. Я проверил статус каждого из них, и все службы работают.

    upstream jenkins {
  keepalive 32;
  server localhost:8090 fail_timeout=0;
}

server {
    server_name build.example.de;

    listen 443 ssl; # managed by Certbot

    access_log  /var/log/nginx/jenkins_access.log;
    error_log   /var/log/nginx/jenkins_error.log;

    ssl_certificate /etc/letsencrypt/live/build.example.de/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/build.example.de/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    location / {
     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_set_header X-Forwarded-Proto $scheme;
     proxy_redirect http:// https://;
     proxy_pass http://jenkins;

     # 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

     # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
     add_header 'X-SSH-Endpoint' 'build.example.de:50022' always;
    }

}

server {
    if ($host = build.example.de) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;

    server_name build.example.de;
    return 404; # managed by Certbot
}

Я всегда получаю сообщение об ошибке:

[error] 8441#8441: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 88.65.0.115, server: build.example.de, request: "GET / HTTP/1.1", upstream: "https://127.0.0.1:8090/", host: "build.example.de"


Jul 26 16:32:10 v22018076557869542 systemd[1]: Starting LSB: Start Jenkins at boot time...
Jul 26 16:32:10 v22018076557869542 jenkins[24446]: Error: Unable to access jarfile jenkins-cli.jar
Jul 26 16:32:10 v22018076557869542 jenkins[24446]: Correct java version found
Jul 26 16:32:10 v22018076557869542 jenkins[24446]:  * Starting Jenkins Automation Server jenkins
Jul 26 16:32:10 v22018076557869542 su[24520]: Successful su for jenkins by root
Jul 26 16:32:10 v22018076557869542 su[24520]: + ??? root:jenkins
Jul 26 16:32:10 v22018076557869542 su[24520]: pam_unix(su:session): session opened for user jenkins by (u
Jul 26 16:32:10 v22018076557869542 su[24520]: pam_unix(su:session): session closed for user jenkins
Jul 26 16:32:11 v22018076557869542 jenkins[24446]:    ...done.
Jul 26 16:32:11 v22018076557869542 systemd[1]: Started LSB: Start Jenkins at boot time.

Что я делаю не так??


1
7 658
1

Ответ:

Решено

Похоже, ваш запрос перенаправлен в восходящий поток: "https://127.0.0.1:8090/", хотя он должен быть простым http, попробуйте удалить прокси_перенаправление http://https://;