2

I currently have

        location /folder1 {
            configuration goes here
        }    

        location /folder2 {
            configuration goes here
        }

I want to serve .mp4 files in these two locations by using the mp4 module

location ~ \.mp4$ {
  mp4;
}

What is the proper way to do this? If I just add location ~ \.mp4$ like above, then wouldn't mp4 files lose configuration from the location folder its in?

2 Answers 2

1
location /folder1 {
    folder1 config;
}    
location ~* ^/folder1/.*\.mp4$ {
    folder1 config duplicated;
    mp4;
}

location /folder2 {
    folder2 config;
}
location ~* ^/folder2/.*\.mp4$ {
    folder2 config duplicated;
    mp4;
}

nginx doesn't try to combine all of the config sections like Apache does, in order to achieve speed and simplicity. The drawback to that is that you'll need to duplicate your folder directives in the location blocks for the mp4 files.

3

Use nested locations:

location /folder1 {

       ...

       location ~ \.mp4$ {
             mp4;
       }
}
4

You must log in to answer this question.

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