| 1 |
user www www; ## Default: nobody |
| 2 |
worker_processes 5; ## Default: 1 |
| 3 |
error_log logs/error.log; |
| 4 |
pid logs/nginx.pid; |
| 5 |
worker_rlimit_nofile 8192; |
| 6 |
|
| 7 |
events { |
| 8 |
worker_connections 4096; ## Default: 1024 |
| 9 |
} |
| 10 |
|
| 11 |
http { |
| 12 |
include conf/mime.types; |
| 13 |
include /etc/nginx/proxy.conf; |
| 14 |
include /etc/nginx/fastcgi.conf; |
| 15 |
index index.html index.htm index.php; |
| 16 |
|
| 17 |
default_type application/octet-stream; |
| 18 |
log_format main '$remote_addr - $remote_user [$time_local] $status ' |
| 19 |
'"$request" $body_bytes_sent "$http_referer" ' |
| 20 |
'"$http_user_agent" "$http_x_forwarded_for"'; |
| 21 |
access_log logs/access.log main; |
| 22 |
sendfile on; |
| 23 |
tcp_nopush on; |
| 24 |
server_names_hash_bucket_size 128; # this seems to be required for some vhosts |
| 25 |
|
| 26 |
server { # php/fastcgi |
| 27 |
listen 80; |
| 28 |
server_name domain1.com www.domain1.com; |
| 29 |
access_log logs/domain1.access.log main; |
| 30 |
root html; |
| 31 |
|
| 32 |
location ~ \.php$ { |
| 33 |
fastcgi_pass 127.0.0.1:1025; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
server { # simple reverse-proxy |
| 38 |
listen 80; |
| 39 |
server_name domain2.com www.domain2.com; |
| 40 |
access_log logs/domain2.access.log main; |
| 41 |
|
| 42 |
# serve static files |
| 43 |
location ~ ^/(images|javascript|js|css|flash|media|static)/ { |
| 44 |
root /var/www/virtual/big.server.com/htdocs; |
| 45 |
expires 30d; |
| 46 |
} |
| 47 |
|
| 48 |
# pass requests for dynamic content to rails/turbogears/zope, et al |
| 49 |
location / { |
| 50 |
proxy_pass http://127.0.0.1:8080; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
upstream big_server_com { |
| 55 |
server 127.0.0.3:8000 weight=5; |
| 56 |
server 127.0.0.3:8001 weight=5; |
| 57 |
server 192.168.0.1:8000; |
| 58 |
server 192.168.0.1:8001; |
| 59 |
} |
| 60 |
|
| 61 |
server { # simple load balancing |
| 62 |
listen 80; |
| 63 |
server_name big.server.com; |
| 64 |
access_log logs/big.server.access.log main; |
| 65 |
|
| 66 |
location / { |
| 67 |
proxy_pass http://big_server_com; |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
# From https://www.nginx.com/resources/wiki/start/topics/examples/full/ |
| 73 |
|