Forward nginx to tomcat doesn't work

Posted December 9, 2017 3.3k views


I configured tomcat with nginx like mentioned in the following tutorials:

My nginx config file now looks like this

# Load modular configuration files from the /etc/nginx/conf.d directory.
    # See
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    upstream tomcat {
    server fail_timeout=0;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
           #try_files $uri $uri/ =404;
        proxy_pass http://tomcat/;
        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;

When I restart nginx and go to my website, I get the following error:

“The page you are looking for is temporarily unavailable. Please try again later.”

While my tomcat server is online.

You can see this on the website:

My tomcat is online at:

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer is not hosted by DigitalOcean.