I have a vanilla installation of nginx on Ubuntu 14.04 and I am trying to run a reverse proxy in front of a Jenkins installation (running on port 8080 as bellow).

I created a conf file to be included in the default configuration and it's picking the new location fine, but it returns a 404 instead of serving the content of the application.

What am I missing? It looks exactly as in the nginx admin guide.

# /etc/nginx/conf.d/reverse_proxy.conf

server {
  listen 80 default_server;
  server_name this_server_name;

  location /jenkins {
    proxy_pass http://localhost:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;

ps (Edit): The 404 is being returned by Jenkins, not nginx.

  • 2
    Considering your PS, shouldn't you be posting your Jenkins configuration and not your nginx configuration? – muru Oct 24 '14 at 3:17
  • Please rephrase your Q and try and explain the actual problem since it seems to stem from Jenkins and has nothing to do with Nginx. – slm Oct 24 '14 at 10:46
  • Jenkins was install from apt-get. No other configuration was performed on it. If I go to the server on port 8080 I get the Jenkins application running correctly. But, if I go via the reverse proxy that I am trying to setup it returns a 404. – Pablo Oct 24 '14 at 11:34

Change your Nginx config

location /jenkins {
    proxy_pass http://localhost:8080/jenkins;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;

Then, reconfigure your jenkins server to accept request with /jenkins by change JENKINS_ARGS in /etc/default/jenkins to something like this

JENKINS_ARGS="--webroot=/var/cache/jenkins/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT --prefix=/jenkins"

You can find details guide at


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.