繁体   English   中英

如何使用Nginx和Node.js应用程序设置Jenkins

[英]How to set up Jenkins with Nginx and a Node.js application

我想要的是

嗨,我的问题如下:我想通过浏览器访问https://my-domain.com/jenkins上运行在服务器上的Jenkins。

我有的

我在运行Ubuntu Nginx的Ubuntu 16.04上具有DO Drop功能,该Nginx充当代理服务器, 通过https将所有流量转发到我的Node.js应用程序 ,当我访问位于https://my-domain.com站点时,它运行良好。

我已经成功安装并运行了Jenkins(如果我运行systemctl status jenkins我可以看到它处于活动状态),但是我不知道应该如何配置Nginx以正确访问Jenkins。

我试图做的是为此设置一个新位置,但是结果是,如果我访问https://my-domain.com/jenkins它将重定向到https://my-domain.com/login?from=%2Fjenkins并为我的Node.js应用程序提供服务。

Nginx配置( /etc/nginx/sites-enabled/default

 server {
        listen 80;
        listen [::]:80 default_server ipv6only=on;
        return 301 https://$host$request_uri;
    }

# HTTPS — proxy all requests to the Node app
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name my-domain.com;

    # Access and error log for Jenkins
    access_log /var/log/nginx/jenkins.access.log;
    error_log /var/log/nginx/jenkins.error.log;

    # Use the Let’s Encrypt certificates
    ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem;

# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://localhost:5000/;
    proxy_ssl_session_reuse off;
    proxy_set_header Host $http_host;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off;

    # Settings for Jenkins
    # include /etc/nginx/proxy_params;
    # proxy_pass http://localhost:8080;
    # proxy_read_timeout 90s;
    # proxy_redirect http://localhost:8080 https://my-domain.com;
}


location /jenkins {
    include /etc/nginx/proxy_params;
    proxy_pass http://localhost:8080;
    proxy_read_timeout 90s;
}
}

也许实际的问题不是与Nginx配置有关,而是与Jenkins有关? 提前致谢!

好的,我知道了。 我意识到,而不是proxy_pass http://localhost:8080; 我不得不使用proxy_pass http://localhost:8080/jenkins/; ,并使用proxy_redirect http:// https://;重定向到https proxy_redirect http:// https://;

如需更多帮助,请访问: https : //wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM