NGINX 配置帮助,多服务器

NGINX 配置帮助,多服务器

我在使用 NGINX 时遇到了一个问题,这很可能是一个简单的修复,但又不可能,因为我对 NGINX 了解不多。

下面是我的 NGINX 配置,运行良好。但我有 3 个其他硬盘驱动器,它们使用相同的脚本,并设置了子域。长话短说,我想我需要添加更多监听服务器,我将 www1.example.com 作为第一个域

然后我有 www2.example.com 等。每个子域名都在自己的硬盘上,我需要将 nginx 指向每个硬盘。有没有办法将其添加到 NGINX 配置中?

这是配置文件。

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


    }

}

答案1

root您的代码块中缺少一条指令server。因此,我认为您现有的网站无法正常运行。

至于添加更多站点,只需创建更多server块即可。

相关内容