I am new in linux world so hope my question is formulated correctly.
I have hosted my .net core app on linux vm (centos) running on localhost:5000 and have nginx set up to access it from outisde. I access this website like this http://myipaddress/
I also installed jenkins and it is running on localhost:8080 inside vm.
I want to configure nginx.config file like that so I had access to jenkins on path http://myipaddress/jenkins
nginx.config file:
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
I think I should add new ‘location’ entry to point to jenkins but not sure how to do it.
any help would be appreciated.
Edit: I am not using docker.
2
Answers
First, you have to configure Jenkins with a context path. You can do this by passing a launch parameter
--prefix=/jenkins
. If you are on docker you can pass it like below.Else you can export the following env variable.
Once that’s done a simple Nginx rule like below should work for you.
-p 50000:50000
: will be used when you connect a slave agent, more detailsSYS_VM_MACHINE:
Edit jenkins config file and add
--prefix=/jenkins
to ‘JENKINS_ARGS’.Nginx config like :