1

I developed a simple JSF application, using Glassfish4 as the application server. Currently it has only one page with administration things. When I run this on localhost everything seems to be in place. But I'd like to put it on a remote server. I've created this nginx configuration:

server {
    listen 80;
    server_name my.domain.name;

    location /jsf {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://0.0.0.0:8080/application;
            proxy_redirect off;
    }
}

And I can open the page, but it is missing the stylesheet. It tries to open the link http://my.domain.name/application/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo but it throws a 404 error.

On localhost the link is the following: http://localhost:8080/application/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo

EDIT: The nginx error log contains lines like this:

2015/07/06 12:58:47 [error] 19916#0: *45 open()
"/usr/share/nginx/html/application/javax.faces.resource/primefaces.js.xhtml;jsessionid=372868209460c2f4d378fac3b8f7"
failed (2: No such file or directory), 
client: [my_IP], server: my.domain.name,
request: "GET /application/javax.faces.resource/primefaces.js.xhtml;jsessionid=372868209460c2f4d378fac3b8f7?ln=primefaces&v=5.2 HTTP/1.1",
host: "my.domain.name",
referrer: "http://my.domain.name/jsf/index.xhtml"

In the Glassfish log I have the following exception:

com.sun.faces.context.FacesFileNotFoundException: /application/javax.faces.resource/theme.css.xhtml Not Found in ExternalContext as a Resource

So I found out that JSF tries to find the resources in the /application (which is the Context Root of the jsf application), but nginx uses /jsf in the location directive. So maybe it means I should use the same name for both..

Rothens
  • 111
  • 4

0 Answers0