6

If there is a way to do this typical task without using aliases, I'm all for it.

I want all requests at the /minesweeper/* URL to be pulled from a completely different directory than other requests. The following configuration WORKS, files are served, but the MIME-type is application/octet-stream instead of what it should be (i.e. text/css). With the incorrect MIME type, it is impossible for web browsers to render the CSS styles in the document.

nginx.conf:
http {
    index index.html
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    ...
}

virtual.conf:
server {
    listen       *:80;
    server_name  djmp.org www.djmp.org;
    root   /home/devsites/djmp.org/public_html/;
    index  index.html;


    location ~ ^/minesweeper($|/.*) {
        alias /home/michael/sites/minesweeper$1;
    }
}

2 Answers 2

1

I fixed the problem by NOT using an alias. ALSO I had to DELETE the cache in Chrome or else it wasn't actually getting the new MIME types! I checked in Firefox and it worked.

server {
    listen       *:80;
    server_name  djmp.org www.djmp.org;
    root   /home/devsites/djmp.org/public_html/;
    index  index.html;
    include       /etc/nginx/mime.types;

    location /minesweeper {
            root   /home/michael/sites/;  # choose the parent directory here
            index  index.html index.htm;
    }

}
1
  • Deleting Chrome cache was the way to go..
    – cjones26
    Jun 8, 2022 at 15:45
1

Using an alias would be fine, but you don't need that regex crap on it.

location /minesweeper/ {
    alias /home/michael/sites/minesweeper/;
}

You must log in to answer this question.

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