簡體   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