0

This is my file in the NginX /sites-enabled directory:

upstream tomcat_server {
    server 192.168.1.100:8080 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name _____.com www._____.com;

    location / {
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://tomcat_server;
    }
}

Right now, the flow goes like this:

  • I visit my domain _____.com, and the request is mapped to the IP of my router at port 39080.
  • In my router, I port forward the request from port 39080 to 192.168.1.136 (where my nginx server is running, separate machine) at port 80.
  • Nginx is listening on port 80 and picks up the request.

What I want it to do is redirect the request to the Tomcat server running on a separate machine, so I put proxy_pass to the Tomcat server.

What actually happens is that the request hangs, and a blank page is on my screen. The Tomcat log shows a 200 OK response to the request, but it should load the rest of the content, including the page and the images and scripts and whatnot.

"GET /app-portal/ HTTP/1.0" 200

// that's it

[/app-portal/ is what my server side code redirects / to]

I can confirm it's nginx's problem because the page loaded with all its content when I changed the router port forwarding directly to the tomcat server instead of nginx.

What could be the problem?

--

I don't know if this a major problem or not, but I notice that the successful requests (from when I go directly from router to tomcat server) is using HTTP1.1, while nginx's failed requests use HTTP1.0

2 Answers 2

1

"proxy_pass http://tomcat_server;" looks odd to me, with that http in there.

Suggest you try removing your upstream and doing it like this.

location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://192.168.1.100:8080
}

This article has a good guide.

0
-1

The proxy_pass should be a full valid domain or IP address. proxy_pass http://tomcat_server; is not valid and leads to no where. if this is the ip of your tomcat server 192.168.1.100:8080 then you should do it like this #proxy_pass http://192.168.1.100:8080; then login to ssh and run this to test the output. wget http://192.168.1.100:8080 hope that helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .