虚拟主机的配置
----------------------------------------------------------------------------------------------
可以基于搭建ip,port,网址虚拟主机:
server
{
listen 8080
;
server_name 172.19.80.90
;
location /
{
proxy_pass http://mysvr
;
root /tmp/nginx/html
;
index index.html index.htm
;
}
}
server
{
listen 80
;
server_name 172.19.80.128
;
location /
{
root /tmp/ng/html
;
index index.html index.htm
;
}
-------------------------------------------------------------------------------------------------
单个配置详解:
server
{
listen 80
;
server_name www.w3cschool.cn w3cschool.cn
;
index index.html index.htm index.php
;
root /data/www/w3cschool
;
location ~ .*.
(php
|php5
)?$
{
fastcgi_pass 127.0.0.1:9000
;
fastcgi_index index.php
;
include fastcgi.conf
;
}
location ~ .*.
(gif
|jpg
|jpeg
|png
|bmp
|swf
)$
{
expires 10d
;
}
location ~ .*.
(js
|css
)?$
{
expires 1h
;
}
log_format access
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /usr/local/nginx/logs/host.access.log main
;
access_log /usr/local/nginx/logs/host.access.404.log log404
;