您的位置:首页 > 运维架构 > 网站架构

制造工厂剖析--组织架构,职能职位

2009-07-01 13:58 489 查看
①:Nginx 基于ip的虚拟主机配置实例

http {

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

server {
listen 80 default;
server_name _;
access_log logs/default.access.log main;

server_name_in_redirect off;
location / {
index index.html index.htm;
root /var/www/default/htdocs;
}
}

server {
listen 80;
server_name 10.5.10.34;
access_log logs/34.access.log main;

location / {
index index.html index.htm;
root /www/nginx/34;
}
}

server {
listen 80;
server_name 10.5.10.35;
access_log logs/35.access.log main;

location / {
index index.html index.htm;
root /www/nginx/35;
}
}

PS:
①基于ip的虚拟主机server的红色部分一定要有否则访问10.5.10.34和35是同一个目录(参看http://wiki.nginx.org/ServerBlockExample).
②由于红色部分中access.log 类型为main 故nginx.conf中默认的日志格式一定要打开(即去掉前面的“#”),否则会出现如下错误信息"2013/03/02 01:22:10 [emerg] 31055#0: unknown log format "main" in /usr/local/nginx/conf/nginx.conf:80"

②基于域名的虚拟主机配置实例
http{
server{
listen 80;
server_name www.a.com;
access_log a.com.access.log combined;

location / {
index index.html index.htm;
root /www/nginx/34;
}
}

server{
listen 80;
server_name www.b.net;
access_log b.net.access.log combined;

location / {
index index.html index.htm;
root /www/nginx/35;
}
}

server{
listen 80;
server_name www.c.org;
access_log c.org.access.log combined;

location / {
index index.html index.htm;
root /www/nginx/36;
}
}

}

以下是我通过chrome和elinks访问的日志信息。




③基于端口的虚拟机主机实例

http{
server{
listen 80;
server_name 10.5.10.34;
access_log port.80.access.log combined;

location / {
index index.html index.htm;
root /www/nginx/34;
}
}

server{
listen 8080;
server_name 10.5.10.34;
access_log port.8080.access.log combined;

location / {
index index.html index.htm;
root /www/nginx/35;
}
}

server{
listen 8081;
server_name 10.5.10.34;
access_log port.8081.access.log combined;

location / {
index index.html index.htm;
root /www/nginx/36;
}
}

}
#elinks 10.5.10.34
#elinks 10.5.10.34:8080
#elinks 10.5.10.34:8081
以下是我用elinks访问基于port虚拟主机的access日志




ps:基于域名和基于端口的虚拟主机不需要像基于ip的添加那段红色代码便可以正常访问。
快乐学习,快乐分享!

本文出自 “Peace与你一起学Linux” 博客,请务必保留此出处http://hepeace.blog.51cto.com/4387185/1143429
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: