Current time: 11-25-2024, 02:18 PM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 5 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ispCP & nginx
Author Message
koffu Offline
Junior Member
*

Posts: 80
Joined: Jan 2010
Reputation: 1
Post: #7
RE: ispCP & nginx
(01-09-2010 04:54 PM)server801 Wrote:  выложи сам скрипт,можь покумекаем

Итак, скрипт в студию! Повторюсь, для сипанели. С рабочего сервера. Не включена только раздача статики из-за особенностей работы программистов - раз, настроено ограничение кол-ва запросов в сек для разных типов:
идея при активации раздачи статики -
mainpage - для /
2proxy - для \.php , который обслуживает апач

Code:
#!/bin/sh

cat > "/usr/local/nginx/conf/nginx.conf" <<EOF
user  nobody;
worker_processes  5;

error_log  logs/error.log info;

worker_rlimit_nofile  8192;

events {
worker_connections  1024; # increase for more busy servers
use epoll; # you should use epoll here for Linux kernels 2.6.x
}

http {
#Limits conn/rate
limit_conn_log_level warn;
limit_zone conn \$binary_remote_addr 10m;

limit_req_zone \$binary_remote_addr zone=mainpage:10m rate=5r/s;
limit_req_zone \$binary_remote_addr zone=2proxy:10m rate=5r/s;

#General
server_names_hash_max_size 2048;
ignore_invalid_headers on;
recursive_error_pages on;
sendfile on;
server_tokens off;

#TCP
tcp_nodelay on;
tcp_nopush on;

#MIME
include    mime.types;
default_type  application/octet-stream;

#Timeouts
keepalive_timeout  5;
client_body_timeout 5;
client_header_timeout 5;
send_timeout 5;

#Compressing
gzip on;
gzip_comp_level 9;
gzip_http_version 1.0;
gzip_vary on;
gzip_min_length  0;
gzip_buffers  16 8k;
gzip_types    text/plain application/x-javascript text/xml text/css;

#Size limits
client_body_buffer_size 8k;
client_header_buffer_size 1k;
large_client_header_buffers 1 1k;

#Proxy
proxy_send_timeout   90;
proxy_read_timeout   90;
proxy_buffer_size    8k;
proxy_buffers     16 64k;
proxy_buffering on;
proxy_cache_valid 1m;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 120s;
proxy_redirect     off;
include "/usr/local/nginx/conf/vhost.conf";
}

EOF

/bin/cp /dev/null /usr/local/nginx/conf/vhost.conf

cd /var/cpanel/users
for USER in *; do
for DOMAIN in `cat $USER | grep ^DNS | cut -d= -f2`; do
IP=`cat $USER|grep ^IP|cut -d= -f2`;
ROOT=`grep ^$USER: /etc/passwd|cut -d: -f6`;
echo "Converting $DOMAIN for $USER";

cat >> "/usr/local/nginx/conf/vhost.conf" <<EOF
server {
access_log off;

error_log  logs/vhost-error_log warn;
listen    80;
server_name  $DOMAIN www.$DOMAIN;

# uncomment location below to make nginx serve static files instead of Apache
# !WARNING!
# it will make the bandwidth accounting incorrect as these files won’t be logged!
#location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css|bmp|csv|doc|epg|gif|ico​|odj|mp3|pdf|swf|txt|xls|xcf|iso)$ {
#root   $ROOT/public_html/;
#}

location / {
proxy_redirect  http://www.$DOMAIN:81   http://www.$DOMAIN;
proxy_redirect  http://$DOMAIN:81   http://$DOMAIN;
proxy_pass   http://$IP:81/;

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

limit_conn conn 5;
limit_req zone=2proxy burst=30;

}
}
EOF
done
done
/etc/init.d/nginx restart
01-09-2010 10:53 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
ispCP & nginx - data-stream_ru - 11-04-2009, 12:50 PM
RE: ispCP & nginx - server801 - 11-04-2009, 08:26 PM
RE: ispCP & nginx - data-stream_ru - 11-07-2009, 02:33 PM
RE: ispCP & nginx - server801 - 11-07-2009, 09:05 PM
RE: ispCP & nginx - koffu - 01-09-2010, 11:10 AM
RE: ispCP & nginx - data-stream_ru - 01-11-2010, 01:45 AM
RE: ispCP & nginx - server801 - 01-09-2010, 04:54 PM
RE: ispCP & nginx - koffu - 01-09-2010 10:53 PM
RE: ispCP & nginx - koffu - 01-10-2010, 10:12 AM
RE: ispCP & nginx - server801 - 01-10-2010, 11:32 PM
RE: ispCP & nginx - koffu - 01-10-2010, 11:37 PM
RE: ispCP & nginx - server801 - 01-11-2010, 12:40 AM
RE: ispCP & nginx - koffu - 01-11-2010, 06:47 AM
RE: ispCP & nginx - server801 - 01-11-2010, 07:40 AM
RE: ispCP & nginx - koffu - 01-11-2010, 07:47 AM
RE: ispCP & nginx - koffu - 01-12-2010, 04:30 PM
RE: ispCP & nginx - data-stream_ru - 01-14-2010, 01:23 AM
RE: ispCP & nginx - data-stream_ru - 01-16-2010, 10:29 PM
RE: ispCP & nginx - koffu - 01-17-2010, 08:10 PM
RE: ispCP & nginx - Kursor - 01-26-2010, 12:30 AM
RE: ispCP & nginx - koffu - 01-26-2010, 01:55 AM
RE: ispCP & nginx - koffu - 01-26-2010, 04:44 AM
RE: ispCP & nginx - marchaos - 01-26-2010, 04:58 AM
RE: ispCP & nginx - koffu - 01-26-2010, 05:02 AM
RE: ispCP & nginx - marchaos - 01-26-2010, 05:41 AM
RE: ispCP & nginx - Kursor - 01-26-2010, 06:07 AM
RE: ispCP & nginx - Kursor - 01-26-2010, 06:20 AM
RE: ispCP & nginx - koffu - 01-26-2010, 06:45 AM
RE: ispCP & nginx - Kursor - 01-26-2010, 07:15 AM
RE: ispCP & nginx - koffu - 01-26-2010, 07:23 AM
RE: ispCP & nginx - Kursor - 01-26-2010, 07:33 AM
RE: ispCP & nginx - koffu - 01-26-2010, 07:38 AM
RE: ispCP & nginx - koffu - 01-27-2010, 07:11 PM
RE: ispCP & nginx - koffu - 01-28-2010, 08:44 AM
RE: ispCP & nginx - data-stream_ru - 01-30-2010, 07:42 PM
RE: ispCP & nginx - koffu - 01-31-2010, 08:30 AM
RE: ispCP & nginx - data-stream_ru - 02-01-2010, 02:53 PM
RE: ispCP & nginx - koffu - 02-01-2010, 06:57 PM
RE: ispCP & nginx - data-stream_ru - 02-01-2010, 08:44 PM
RE: ispCP & nginx - koffu - 02-03-2010, 08:59 AM
RE: ispCP & nginx - data-stream_ru - 02-03-2010, 09:30 PM
RE: ispCP & nginx - koffu - 02-05-2010, 07:56 AM
RE: ispCP & nginx - data-stream_ru - 02-05-2010, 06:30 PM
RE: ispCP & nginx - data-stream_ru - 02-12-2010, 04:53 PM
RE: ispCP & nginx - data-stream_ru - 02-12-2010, 06:09 PM
RE: ispCP & nginx - data-stream_ru - 02-12-2010, 10:18 PM
RE: ispCP & nginx - data-stream_ru - 02-12-2010, 11:34 PM
RE: ispCP & nginx - koffu - 02-13-2010, 12:44 AM
RE: ispCP & nginx - data-stream_ru - 02-13-2010, 01:53 AM
RE: ispCP & nginx - koffu - 02-13-2010, 01:59 AM
RE: ispCP & nginx - data-stream_ru - 02-13-2010, 02:56 AM
RE: ispCP & nginx - data-stream_ru - 02-13-2010, 05:29 AM
RE: ispCP & nginx - data-stream_ru - 02-13-2010, 07:12 AM
RE: ispCP & nginx - data-stream_ru - 02-13-2010, 12:53 PM
RE: ispCP & nginx - koffu - 02-13-2010, 06:52 PM
RE: ispCP & nginx - data-stream_ru - 02-14-2010, 01:40 AM
RE: ispCP & nginx - data-stream_ru - 02-15-2010, 07:07 AM
RE: ispCP & nginx - data-stream_ru - 02-17-2010, 08:06 PM
RE: ispCP & nginx - koffu - 02-18-2010, 08:21 AM
RE: ispCP & nginx - data-stream_ru - 02-18-2010, 09:23 PM
RE: ispCP & nginx - koffu - 02-18-2010, 09:25 PM
RE: ispCP & nginx - data-stream_ru - 02-19-2010, 07:43 AM
RE: ispCP & nginx - data-stream_ru - 02-22-2010, 06:36 AM
RE: ispCP & nginx - data-stream_ru - 02-23-2010, 11:27 AM
RE: ispCP & nginx - marchaos - 02-26-2010, 04:48 AM
RE: ispCP & nginx - data-stream_ru - 02-26-2010, 07:49 AM
RE: ispCP & nginx - marchaos - 02-26-2010, 06:03 PM
RE: ispCP & nginx - server801 - 02-27-2010, 05:27 AM
RE: ispCP & nginx - koffu - 02-27-2010, 07:11 AM
RE: ispCP & nginx - SolarW - 02-27-2010, 07:29 AM
RE: ispCP & nginx - data-stream_ru - 02-27-2010, 09:05 AM
RE: ispCP & nginx - SolarW - 02-28-2010, 09:33 AM
RE: ispCP & nginx - marchaos - 02-27-2010, 10:14 AM
RE: ispCP & nginx - data-stream_ru - 02-27-2010, 10:56 AM
RE: ispCP & nginx - marchaos - 02-27-2010, 11:03 AM
RE: ispCP & nginx - data-stream_ru - 02-27-2010, 11:57 PM
RE: ispCP & nginx - data-stream_ru - 02-28-2010, 01:30 AM
RE: ispCP & nginx - koffu - 03-01-2010, 06:28 AM
RE: ispCP & nginx - server801 - 03-01-2010, 06:38 AM
RE: ispCP & nginx - data-stream_ru - 03-02-2010, 11:45 AM
RE: ispCP & nginx - data-stream_ru - 03-02-2010, 12:45 PM
RE: ispCP & nginx - data-stream_ru - 03-02-2010, 01:47 PM
RE: ispCP & nginx - data-stream_ru - 03-02-2010, 03:01 PM
RE: ispCP & nginx - data-stream_ru - 03-02-2010, 09:49 PM
RE: ispCP & nginx - server801 - 03-03-2010, 02:32 AM
RE: ispCP & nginx - data-stream_ru - 03-03-2010, 04:44 PM
RE: ispCP & nginx - data-stream_ru - 03-04-2010, 03:18 AM
RE: ispCP & nginx - data-stream_ru - 03-04-2010, 04:59 PM
RE: ispCP & nginx - data-stream_ru - 03-04-2010, 06:27 PM
RE: ispCP & nginx - koffu - 03-11-2010, 11:01 PM
RE: ispCP & nginx - data-stream_ru - 03-12-2010, 02:11 AM
RE: ispCP & nginx - GioMac - 03-16-2010, 07:31 AM
RE: ispCP & nginx - marchaos - 03-16-2010, 07:40 AM
RE: ispCP & nginx - GioMac - 03-16-2010, 08:19 AM
RE: ispCP & nginx - koffu - 03-18-2010, 10:19 PM
RE: ispCP & nginx - GioMac - 03-19-2010, 11:55 PM
RE: ispCP & nginx - data-stream_ru - 03-19-2010, 12:26 AM
RE: ispCP & nginx - data-stream_ru - 03-20-2010, 09:38 AM
RE: ispCP & nginx - data-stream_ru - 03-20-2010, 10:45 PM
RE: ispCP & nginx - data-stream_ru - 03-26-2010, 06:06 PM
RE: ispCP & nginx - GioMac - 03-28-2010, 10:57 AM
RE: ispCP & nginx - data-stream_ru - 03-28-2010, 06:44 PM
RE: ispCP & nginx - GioMac - 03-28-2010, 07:00 PM
RE: ispCP & nginx - server801 - 03-28-2010, 09:49 PM
RE: ispCP & nginx - data-stream_ru - 03-29-2010, 12:45 AM
RE: ispCP & nginx - GioMac - 03-29-2010, 05:21 AM
RE: ispCP & nginx - mad max - 03-29-2010, 05:15 AM
RE: ispCP & nginx - data-stream_ru - 03-29-2010, 09:31 AM
RE: ispCP & nginx - TTP - 05-04-2010, 10:02 PM
RE: ispCP & nginx - server801 - 03-29-2010, 07:26 AM
RE: ispCP & nginx - GioMac - 03-29-2010, 08:51 AM
RE: ispCP & nginx - data-stream_ru - 05-01-2010, 04:02 AM
RE: ispCP & nginx - server801 - 05-01-2010, 08:13 PM
RE: ispCP & nginx - data-stream_ru - 05-04-2010, 01:27 AM
RE: ispCP & nginx - data-stream_ru - 05-06-2010, 08:35 AM
RE: ispCP & nginx - TTP - 05-06-2010, 05:45 PM
RE: ispCP & nginx - koffu - 06-03-2010, 06:42 PM
RE: ispCP & nginx - koffu - 07-28-2010, 02:46 AM
RE: ispCP & nginx - data-stream_ru - 07-28-2010, 04:07 PM
RE: ispCP & nginx - DragonZX - 08-27-2010, 07:13 AM
RE: ispCP & nginx - data-stream_ru - 08-27-2010, 07:23 PM
RE: ispCP & nginx - koffu - 07-28-2010, 05:05 PM
RE: ispCP & nginx - koffu - 08-27-2010, 11:29 PM
RE: ispCP & nginx - koffu - 08-28-2010, 01:19 AM
RE: ispCP & nginx - DragonZX - 08-28-2010, 03:49 AM
RE: ispCP & nginx - koffu - 08-29-2010, 02:01 AM
RE: ispCP & nginx - koffu - 09-03-2010, 12:42 AM
RE: ispCP & nginx - server801 - 09-03-2010, 02:17 AM
RE: ispCP & nginx - koffu - 09-07-2010, 10:15 PM
RE: ispCP & nginx - DragonZX - 09-09-2010, 06:47 PM
RE: ispCP & nginx - koffu - 09-09-2010, 10:24 PM
RE: ispCP & nginx - koffu - 09-17-2010, 11:01 PM
RE: ispCP & nginx - Enkil - 09-21-2010, 06:08 AM
RE: ispCP & nginx - koffu - 09-21-2010, 06:48 AM
RE: ispCP & nginx - Enkil - 09-21-2010, 08:06 AM
RE: ispCP & nginx - Enkil - 09-21-2010, 09:47 AM
RE: ispCP & nginx - koffu - 09-21-2010, 04:19 PM
RE: ispCP & nginx - Enkil - 09-22-2010, 08:09 AM
RE: ispCP & nginx - koffu - 09-22-2010, 08:36 AM
RE: ispCP & nginx - server801 - 09-22-2010, 06:40 PM
RE: ispCP & nginx - DragonZX - 09-22-2010, 11:55 PM
RE: ispCP & nginx - koffu - 09-23-2010, 03:37 AM
RE: ispCP & nginx - Enkil - 09-26-2010, 06:34 AM
RE: ispCP & nginx - koffu - 09-30-2010, 04:33 AM
RE: ispCP & nginx - DragonZX - 09-30-2010, 05:50 AM
RE: ispCP & nginx - alt - 10-11-2010, 05:10 PM
RE: ispCP & nginx - data-stream_ru - 09-23-2010, 09:42 AM
RE: ispCP & nginx - Enkil - 09-30-2010, 05:53 AM
RE: ispCP & nginx - koffu - 09-30-2010, 06:48 AM
RE: ispCP & nginx - DragonZX - 09-30-2010, 07:37 AM
RE: ispCP & nginx - Enkil - 09-30-2010, 06:06 PM
RE: ispCP & nginx - DragonZX - 09-30-2010, 06:34 PM
RE: ispCP & nginx - Enkil - 09-30-2010, 07:21 PM
RE: ispCP & nginx - DragonZX - 09-30-2010, 09:40 PM
RE: ispCP & nginx - Enkil - 09-30-2010, 10:45 PM
RE: ispCP & nginx - koffu - 10-09-2010, 01:14 AM
RE: ispCP & nginx - DragonZX - 10-01-2010, 12:29 AM
RE: ispCP & nginx - Enkil - 10-01-2010, 02:22 AM
RE: ispCP & nginx - DragonZX - 10-01-2010, 02:38 AM
RE: ispCP & nginx - outbackdingo - 10-01-2010, 12:20 PM
RE: ispCP & nginx - DragonZX - 10-01-2010, 04:29 PM
RE: ispCP & nginx - alt - 10-08-2010, 09:06 PM
RE: ispCP & nginx - DragonZX - 10-12-2010, 10:25 PM
RE: ispCP & nginx - server801 - 10-12-2010, 11:42 PM
RE: ispCP & nginx - DragonZX - 10-13-2010, 12:32 AM
RE: ispCP & nginx - data-stream_ru - 10-25-2010, 02:49 PM
RE: ispCP & nginx - data-stream_ru - 02-21-2011, 11:37 PM
RE: ispCP & nginx - server801 - 02-23-2011, 07:41 AM
RE: ispCP & nginx - koffu - 03-01-2011, 10:18 PM
RE: ispCP & nginx - koffu - 09-21-2011, 10:13 PM
RE: ispCP & nginx - DragonZX - 09-22-2011, 12:39 AM

Forum Jump:


User(s) browsing this thread: 39 Guest(s)