以三台电脑为示例:nginx:10.1.1.195 web1:10.1.1.196 web210.1.1.197
编辑10.1.1.195的Nginx配置文件nginx.conf
- user nginx nginx;
- worker_processes 5;
- error_log logs/error.log info;
- pid logs/nginx.pid;
-
- events {
- use epoll;
- worker_connections 65535;
- }
-
- http {
-
- server {
- listen 80;
- server_name 10.1.1.195;
- root /nginxroot/;
-
- location /images/ {
- proxy_pass http://10.1.1.197/; --这里后面得加/
- }
- location ~ \.(txt|php)$ {
- proxy_pass http://10.1.1.196; --这里后面不能加/
- }
- }
- }
--这里是做的七层代理,上面的配置表示访问10.1.1.195/images/时会调给后面的197的80端口;访问任何以.txt或.php结尾的文件时会调给196的80端口;其它的由195的nginx自己解析