`
sillycat
  • 浏览: 2542580 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Server Deployment - nginx

阅读更多
Server Deployment - nginx

1. proxy configuration
The configuration file is /etc/nginx/nginx.conf, but I can change another file:
>vi /etc/nginx/conf.d/easymarket.conf
configuration files:
log_format main '$remote_addr - $remote_user [$time_local] $request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

upstream easy {
        ip_hash;
        server localhost:8083;
        server localhost:8084;
        server localhost:8085;
}

server {
        listen       83;
        server_name localhost;

        charset utf-8;

        access_log logs/host.access.log main;

        location /nginxstatus {
           stub_status on; #nginx status watch
           access_log off;
        }

        location / {
           proxy_pass http://easy;
           proxy_set_header X-Real-IP $remote_addr;
        }

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

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

we can see the status with URL
http://localhost:83/nginxstatus

2. config the perl cgi
The configuration file easymarket.conf will be as follow:
log_format main '$remote_addr - $remote_user [$time_local] $request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

upstream easy {
        ip_hash;
        server localhost:8083;
        server localhost:8084;
        server localhost:8085;
}

server {
        listen       83;
        server_name localhost;

        charset utf-8;

        access_log logs/host.access.log main;
        root /var/www;

        location /nginxstatus {
           stub_status on; #nginx status watch
           access_log off;
        }

        location ~\.pl$ {
           gzip off;
           include /etc/nginx/fastcgi_params;
           fastcgi_pass unix:/var/run/fcgiwrap.socket;
           fastcgi_index index.pl;
           fastcgi_param SCRIPT_FILENAME /var/www/easyperl$fastcgi_script_name;
        }


        location /easymarket {
           proxy_pass http://easy;
           proxy_set_header X-Real-IP $remote_addr;
        }

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

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

Test the Perl page:
http://localhost:83/easyperl/Action.pl
http://localhost:83/easyperl/All.pl

references:
http://hi.baidu.com/luohuazju/blog/item/8baa8f1738303c0a4b90a771.html
http://hi.baidu.com/luohuazju/blog/item/f7880d822e5f12b86c811902.html
http://library.linode.com/web-servers/nginx/perl-fastcgi/ubuntu-11.04-natty

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics