Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


below is the config + error it's throwing, can't for the life of me figure out what's wrong. Tried all sorts to get it working to no avail :(

server  {

    access_log      /var/log/nginx/main.proxied.log;

    location        ^~/(error_pages|javascript|stylesheets|help|images|xml|graphs|static|media) {
    root    /usr/local/nagios/share;

    location ~* \.(js|css|rdf|xml|ico|txt|gif|jpg|png|jpeg)$ {
    root    /usr/local/nagios/share/;

location / {

    proxy_redirect  off;

    proxy_set_header        Host    $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

    client_max_body_size    10m;

And the error;

Restarting nginx: [warn]: duplicate MIME type "text/html" in /etc/nginx/nginx.conf:29
[emerg]: location "/" is outside location "/(error_pages|javascript|stylesheets|help|images|xml|graphs|static|media)" in /etc/nginx/sites-enabled/main.conf:13
configuration file /etc/nginx/nginx.conf test failed
share|improve this question
up vote 2 down vote accepted

You have mismatched curly brackets.

The line:

location        ^~/(error_pages|javascript|stylesheets|help|images|xml|graphs|static|media) {

Has an open-curly-bracket at the end of it but there is no closing curly bracket before the next location line.

What @memoryleak wrote is true also, if you close both of those location blocks, the existing close-curly-bracket will be closing the server block meaning the final location is now in the wrong context.

The final location block also has no closing curly-bracket.

share|improve this answer

In your configuration file location is outside of server directive, but the context of location is inside server:

share|improve this answer

Your Answer


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.