多个nginx子域导致一个码头实例

时间:2019-03-27 22:20:28

标签: nginx jenkins jetty nginx-reverse-proxy

我在nginx上添加了多个子域,现在我想将所有子域代理传递给单个码头实例。

说 subdomain1.blog.com->本地主机:8080 / subdomain1 jenkins.blog.com->本地主机:8080 / jenkins

我测试了很多示例,最后我在URL上苦苦挣扎。 如果我打开http://jenkins.blog.com,我将重定向到https://jenkins.blog.com/jenkins/login?from=%2Fjenkins%2F

如何在我的网址中删除此/ jenkins /? 是否可以不使用多个码头实例并在webroot上部署应用程序来实现?

upstream jetty {
    server 127.0.0.1:8080 fail_timeout=0;
}

server {
    listen 80;
    server_name jenkins.blog.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name jenkins.blog.com;

    ssl_certificate /etc/letsencrypt/live/blog.com-0002/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/blog.com-0002/privkey.pem;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;


   location /jenkins {
     rewrite ^/jenkins(/.*)$ $1 last;
   }


    location / {
      proxy_set_header        Host $http_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 $scheme;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      proxy_pass       http://jetty/jenkins/;
      proxy_read_timeout  90;

      #proxy_redirect      http://localhost:8080/jenkins    https://jenkins.blog.com;
      #proxy_redirect      http:// https://;

      proxy_redirect       off;
      proxy_buffering      off;
      # Required for new HTTP-based CLI
      proxy_http_version 1.1;
      proxy_request_buffering off;
      # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
      add_header 'X-SSH-Endpoint' 'jenkins.blog.com:50022' always;     
    }
 }
}

0 个答案:

没有答案