首页 > 代码库 > window 下 nginx的反响代理配置
window 下 nginx的反响代理配置
大致情况是:给nginx配置两个域名,一个专门来处理静态资源的请求:172.17.2.137:9001
一个是处理动态请求:www.palmpaly.com 这个域名根据后面的路径又反向代理到两个不同的服务器,
一个服务器专门处理文件上传,一个服务器处理其他的action请求
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#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 logs/access.log main;
client_max_body_size 500m;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream palmnager.com { #上传
server 172.17.2.137:8081;
}
upstream palmnager2.com {
server 172.17.2.137:8082;
}
server {
listen 9001;
server_name 172.17.2.137;
charset utf-8;
#设置网站的根目录
location / {
root E:/nginx-static;
}
}
server {
listen 80;
server_name www.palmpaly.com;
charset utf-8;
location /PalmplayUpload/{
proxy_pass http://palmnager.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /PalmplayManager/{
proxy_pass http://palmnager2.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
本文出自 “重新来学JAVA” 博客,请务必保留此出处http://3131854.blog.51cto.com/3121854/1550057
window 下 nginx的反响代理配置