listen 80;
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log main;
location = / {
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:8080;
}
location = /index.html {
root ainusers.com.bak;
index ainusers_ip.html index.html index.htm;
}
location /index.html {
root ainusers.com;
index ainusers_port.html index.html index.htm;
}
location /xxx {
if ( $remote_addr = '192.168.79.1' ) {
rewrite ^.*$ /ainusers_ip.html break;
}
root ainusers.com;
index ainusers_port.html index.html index.htm;
}
location /ainusers_ip.html {
if ( $remote_addr = '192.168.79.1' ) {
# rewrite ^.*$ /ainusers_port.html break;
rewrite /ainusers_ip.html /index.html break;
}
root ainusers.com;
index ainusers_port.html index.html index.htm;
}
location /ainusers_port.html {
proxy_pass http://127.0.0.1:80;
}
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log main;
location = / {
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:8080;
}
location = /index.html {
root ainusers.com.bak;
index ainusers_ip.html index.html index.htm;
}
location /index.html {
root ainusers.com;
index ainusers_port.html index.html index.htm;
}
location /xxx {
if ( $remote_addr = '192.168.79.1' ) {
rewrite ^.*$ /ainusers_ip.html break;
}
root ainusers.com;
index ainusers_port.html index.html index.htm;
}
location /ainusers_ip.html {
if ( $remote_addr = '192.168.79.1' ) {
# rewrite ^.*$ /ainusers_port.html break;
rewrite /ainusers_ip.html /index.html break;
}
root ainusers.com;
index ainusers_port.html index.html index.htm;
}
location /ainusers_port.html {
proxy_pass http://127.0.0.1:80;
}
本文详细介绍了Nginx服务器的配置方法,包括监听端口、域名设置、代理传递及重写规则等内容。通过实例展示了如何针对不同请求进行响应处理。
1815

被折叠的 条评论
为什么被折叠?



