Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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;
    }
}
share|improve this question
add comment

2 Answers

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;
    }

}
share|improve this answer
add comment

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

location /minesweeper/ {
    alias /home/michael/sites/minesweeper/;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.