1)监控8000端口访问,则跳转到http://www.baidu.com
worker_processes 1;
events {worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8000;
server_name localhost;
rewrite ^(.*) http://www.baidu.com;
}
}
2) 集群配置,一个nginx 配置一个集群环境:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream duoju_jiqun{
server 127.0.0.1:8081 weight=1;
server 127.0.0.1:8082 weight=1;
}
server {
listen 8080;
server_name 127.0.0.1;
location / {
proxy_pass http://duoju_jiqun;
proxy_redirect default;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
3) 集群配置,一个nginx 配置两个集群环境:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream duoju_jiqun1{
server 127.0.0.1:8081 weight=1;
server 127.0.0.1:8082 weight=1;
}
upstream duoju_jiqun2{
server 127.0.0.1:8083 weight=1;
server 127.0.0.1:8084 weight=1;
}
server {
listen 8080;
server_name 127.0.0.1;
location /test1/ {
proxy_pass http://duoju_jiqun1;
proxy_redirect default;
}
location /test2/ {
proxy_pass http://duoju_jiqun2;
proxy_redirect default;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}