nginx 反向代理设置成功,但是能不能做目录的反向代理呢? 已附配置文件
通过 nginx , 用户访问我的域名能转向到另外一台服务器了, 但是,,能不能做个目录的反向代理呢
80 访问
比如说用户访问 199.look333.com/139 这样,就解释到 59.102.105.139/web
443 访问
用户访问 https://199.look333.com/140 这样,就解释到 https://59.102.105.140/web
[root@ conf]# more nginx.conf
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /usr/local/nginx/conf/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 120;
upstream 199.look333.com {
server 59.102.105.139:80;
}
server {
listen 80;
server_name 199.look333.com;
location / {
proxy_pass http://199.look333.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 443;
server_name 199.look333.com;
access_log /var/log/nginx/live.access.log main;
error_log /var/log/nginx/live.error_log info;
ssl on;
ssl_certificate /usr/local/nginx/ssl.crt;
ssl_certificate_key /usr/local/nginx/ssl.key;
keepalive_timeout 70;
add_header Front-End-Https on;
location / {
proxy_pass http://199.look333.com;
auth_basic "kkkload";
auth_basic_user_file /usr/local/nginx/conf/htpasswd;
}
}
}