Static files not requested with correct url


I have a multi docker contained architecture set up to run Omeka. I have Omeka running in a contained with php and apache2 on. I have a separate mysql container and a separate nginx container.

When I connect directly to the omeka container everything works correctly.

When I connect to the omeka contained through the nginx container it can’t find the static files. The problem appears to be that in nginx I am proxying to omeka only when I have a directory in the url. The nginx redirect looks like this:

        location /sw/ {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://omeka/;

The PHP files are served correctly, but static files are lost - I believe this is because omeka does not know it needs to add the directory to all the file requests (e.g. instead of http://mysite/style.css it should be http://mysite/sw/style.css).

Is there any way to set a subfolder in all static file (i.e. js, css, jpeg, etc) requests?

So I presume the problem here is that nginx is stripping the /sw/ prefix before it proxies the request on to the Omeka container: the result is that it ends up at Omeka correctly (as you say, the PHP works), but the server sees you connecting to just the root, so that’s where it generates URLs for. (Actually, can you link between the PHP-generated pages? I’d expect that to be broken as well).

I believe if you remove the trailing slash from the proxy_pass directive, nginx won’t strip the /sw/, but then you’d have to reconfigure your Omeka container’s server to respond to requests there, in addition to or instead of at the root.

One silly but workable solution would be to just create a sw folder in the Omeka container and move the site into that, then either remove the slash from the proxy_pass or explicitly add /sw/ to the end of it, which should make things work just because the two paths will match.

Thanks John,

You suggestions worked well. You were right the links on the PHP files also weren’t working. I removed the trailing slash and moved Omeka into a subfolder.

If anyone is interested the docker container is here: