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

I am having an issue with NGINX , this could quite possibly be an easy fix then again could not be I just don't know that much about NGINX.

I have my NGINX config below which works great. But I have 3 other hard drives with the same script that are set up with subdomains. So to make a long story short I need to add more listening servers I guess, I have www1.example.com as first domain

and then I have www2.example.com etc. Each subdomain is on its own hard drive and I need to point nginx to each one of those hard drives. Is there a way to add the into the NGINX config?

Here is the config file.

#user  nobody;
worker_processes  4;
worker_rlimit_nofile 30000;
worker_rlimit_sigpending 32768;

error_log  logs/error.log  error;

#pid        logs/nginx.pid;


events {
    worker_connections  4096;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    access_log  off;
    limit_conn_log_level info;

    #sendfile       on;
    #tcp_nopush     on;
    reset_timedout_connection on;

    server_tokens off;
    autoindex off;

    keepalive_timeout  0;
    #keepalive_timeout  65;

    limit_conn_zone $binary_remote_addr zone=one:10m;
    perl_modules  perl;
    perl_require  download.pm;

    server {
        listen       182;
        server_name  example.com;
        proxy_set_header X-Real-IP $remote_addr;

        #charset koi8-r;

        location /nstatus {
            stub_status on;
            #allow 127.0.0.1;
            #deny all;
                        }

        location / {
            root   html;
            index  index.html index.htm;
        }

        location /d/ {
            perl  download::handler;
        }

        # Free
        location /download_f/ {
            alias /example.com/uploads/;
            internal;
            set $limit_rate $arg_speed;
            limit_conn one 5;
        }

        # Registered
        location /download_r/ {
            alias /example.com/uploads/;
            internal;
            set $limit_rate $arg_speed;
            limit_conn one 5;
        }

        # Premium
        location /download_p/ {
            alias /example.com/uploads/;
            internal;
            set $limit_rate $arg_speed;
            limit_conn one 10;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

         server {
        listen       182;
        server_name  2.example.com;
        proxy_set_header X-Real-IP $remote_addr;

        #charset koi8-r;

        location /nstatus {
            stub_status on;
            #allow 127.0.0.1;
            #deny all;
                        }

        location / {
            root   html;
            index  index.html index.htm;
        }

        location /d/ {
            perl  download::handler;
        }

        # Free
        location /download_f/ {
            alias /2.example.com/uploads/;
            internal;
            set $limit_rate $arg_speed;
            limit_conn one 5;
        }

        # Registered
        location /download_r/ {
            alias /2.example.com/uploads/;
            internal;
            set $limit_rate $arg_speed;
            limit_conn one 5;
        }

        # Premium
        location /download_p/ {
            alias /2.example.com/uploads/;
            internal;
            set $limit_rate $arg_speed;
            limit_conn one 10;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }


    }

}
share|improve this question

1 Answer 1

You're missing a root directive in your server block. So I don't expect your existing site to work without issues.

As for adding more sites, just create more server blocks.

share|improve this answer
    
when I add more server blocks it says nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:51 when I try to start nginx –  Blackhawk1xx Mar 27 '13 at 21:04
    
You can't nest them. Add the new server block after the last one. –  Michael Hampton Mar 27 '13 at 21:08
    
Take a look, I added just like that, with all the correct directories, and still it says I am not allowed to use the "server" directive. –  Blackhawk1xx Mar 27 '13 at 21:15
    
Can you write the way it should be with the additional server block :)? –  Blackhawk1xx Mar 27 '13 at 21:23
    
And your right, it is not so working now again... –  Blackhawk1xx Mar 27 '13 at 22:37

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.