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.

Hihi,

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  {
    listen  127.0.0.1:100;

    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_pass      http://127.0.0.1:80/;
    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

2 Answers 2

up vote 1 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: http://wiki.nginx.org/HttpCoreModule#location

share|improve this answer

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.