Nginx 404 not found for Java web service
<p>I have no issue dealing with glassfish directly (with no Nginx). The issue comes when I access it through Nginx.</p>

<p>I have two servers: MY_NGINX_IP and MY_GLASSFISH_IP:8080</p>

<p>Basically, the <a href="http://MY_NGINX_IP" rel="nofollow noreferrer">http://MY_NGINX_IP</a> works just fine and displays the index file. However, <a href="http://MY_NGINX_IP/webservice/v1/employee" rel="nofollow noreferrer">http://MY_NGINX_IP/webservice/v1/employee</a> gives a 404 not found error.</p>

<p>While <a href="http://MY_GLASSFISH_IP:8080/webservice/v1/employee" rel="nofollow noreferrer">http://MY_GLASSFISH_IP:8080/webservice/v1/employee</a> works just fine.</p>

<p>Note: <a href="http://MY_NGINX_IP" rel="nofollow noreferrer">http://MY_NGINX_IP</a> produces the index file with no issues. Only when append /webservice/v1/employee to it then the error comes.</p>

<p>Hint: I am using Nginx v1.10.1 on Ubuntu</p>

<p>My upstreamm:</p>

<pre><code>        upstream myownstream {
            server MY_SERVER_IP:8080;
    }
</code></pre>

<p>My location config:</p>

<pre><code>        location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
            proxy_pass http://myownstream;
            #proxy_pass http://127.0.0.1:8080;
            proxy_next_upstream  error timeout invalid_header http_500;
            proxy_connect_timeout 5;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;
            proxy_set_header Host $host;
    }
</code></pre>