简体   繁体   中英

Does Nginx support multiple ports forward with a single Jenkins instance?

We have 3 Jenkins instances for DEV/STG/PRD in a single CI Server. It uses 3001,3002 and 3003 TCP ports for each. For example, If I want to access STG Jenkins, I can access the server with the URL "192.168.0.3:3002".

But now we have to move the Jenkins instances to behind Nginx Server for remote users, the users only can access the Jenkins through Nginx and port no 443. Only TCP 443 port of their Fire Wall is opened for outbound traffic. Because of this reason(Single Nginx instance of TCP 443), the only way to distinguish between DEV/STG/PRD is to use different URI.

For example:

  • "192.168.0.3:3001" --> "192.168.0.3:443/dev"
  • "192.168.0.3:3002" --> "192.168.0.3:443/stg"
  • and so on.

Below is a sample NginX configuration for port forward I expect.

server (
listen 443;
server_name localhost;
location /dev (
proxy_pass http://localhost:3001;
)
location /stg (
proxy_pass http://localhost:3002;
)
location /prd (
proxy_pass http://localhost:3003;
)
)

Is it possible? Does Nginx support multiple ports forward with a single instance?

Yes, Nginx supports multiple upstream, the only change you need to make is to customise Jira server XML config path:

See full config below: https://gist.github.com/mikhailov/8562320

    <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
        <Context path="/jira" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true">
          <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
            factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
          <Manager pathname=""/>
        </Context>
      </Host>
    ....
    </Engine>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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