[Email protected] extra]# cat/etc/nginx/nginx.conf
User Nginx Nginx;
Worker_processes 6;
Error_log/app/log/nginx_error.log Crit;
Pid/app/log/nginx.pid;
Events {
Use Epoll;
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";
Access_log/app/log/http.access.log main;
Keepalive_timeout 65;
include/extra/*.conf;
}
[Email protected] extra]#
[email protected] extra]# cat www.conf
server {
Listen 80;
server_name www.etangbo.com;
Access_log/app/log/www/host.access.log main;
Location/{
root/data/www;
Index index.html index.htm;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
[email protected] extra]# cat bbs.conf
###
server {
Listen 8081;
server_name bbs.etangbo.com;
Access_log/app/log/bbs/host.access.log main;
Location/{
Root/data/bbs;
Index index.html index.htm;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
[email protected] extra]# cat blog.conf
###
server {
Listen 8080;
server_name blog.etangbo.com;
Access_log/app/log/blog/host.access.log main;
Location/{
Root/data/blog;
Index index.html index.htm;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
[Email protected] extra]#
################################################
Also can do IP-based virtual host, this is not demonstrated, very simple
This article from "Bobcat" blog, declined reprint!
Nginx Port-based virtual host: