Исходные данные: машина c FreeBSD 8.2 (один IP), nginx (front-end) в режиме проксирования, apache (back-end).
Конфиги:
httpd-vhosts.conf
Код: Выделить всё
NameVirtualHost *:8888
<VirtualHost *:8888>
DocumentRoot "/usr/local/www/domain.ru/"
ServerAdmin webmaster@domain.ru
ServerName domain.ru
Alias /php-fcgi/ "/usr/local/www/cgi-bin/"
ErrorLog "/var/log/sites/domain.er-httpd.log"
CustomLog "/var/log/sites/domain.ac-httpd.log" combined
<Directory "/usr/local/www/domain.ru/">
Options None
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *:8888>
ServerAdmin webmaster@domain.ru
DocumentRoot "/usr/local/www/edit/"
ServerName edit.domain.ru
# SuexecUserGroup ucgi ucgi
Alias /php-fcgi/ "/usr/local/www/cgi-bin/"
ErrorLog "/var/log/sites/edit.er-httpd.log"
CustomLog "/var/log/sites/edit.ac-httpd.log" combined
<Directory "/usr/local/www/edit/">
Options FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from All
Satisfy All
</Directory>
</VirtualHost>
Код: Выделить всё
user www www;
worker_processes 3;
error_log /var/log/sites/error-nginx.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use kqueue;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
access_log /var/log/sites/access-nginx.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_proxied any;
gzip_min_length 1100;
gzip_http_version 1.0;
gzip_buffers 4 8k;
gzip_comp_level 9;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# ----------------------------------------------------------------------------
upstream main {
server domain.ru:8888;
}
server {
listen 80;
server_name domain.ru;
client_max_body_size 50M;
access_log /var/log/sites/pro.ac-nginx.log;
error_log /var/log/sites/pro.er-nginx.log;
location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ {
root /usr/local/www/domain.ru;
index index.html index.php;
access_log off;
expires 30d;
}
location ~ /\.ht {
deny all;
}
location / {
proxy_pass http://main;
include proxy.conf;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
# ----------------------------------------------------------------------------
upstream edit {
server edit.domain.ru:8888;
}
server {
listen 443;
server_name edit.domain.ru;
ssl on;
ssl_certificate /usr/local/etc/ssl/mail_public_cert.pem;
ssl_certificate_key /usr/local/etc/ssl/mail_private_key.pem;
access_log /var/log/sites/edit.ac-nginx-ssl.log;
error_log /var/log/sites/edit.er-nginx-ssl.log;
auth_basic "NO TRESPASSING!!!";
auth_basic_user_file /usr/local/www/edit/.htpasswd;
location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ {
root /usr/local/www/edit;
index index.html index.php;
access_log off;
expires 30d;
}
location ~ /\.ht {
deny all;
}
location / {
proxy_pass http://edit;
include proxy.conf;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
server {
listen 80;
server_name edit.domain.ru;
access_log /var/log/sites/edit.ac-nginx.log;
error_log /var/log/sites/edit.er-nginx.log;
auth_basic "NO TRESPASSING!!!";
auth_basic_user_file /usr/local/www/edit/.htpasswd;
location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ {
root /usr/local/www/edit;
index index.html index.php;
access_log off;
expires 30d;
}
location ~ /\.ht {
deny all;
}
location / {
proxy_pass http://edit;
include proxy.conf;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
}