nginx反向代理

##IP地址規劃

主機名 IP地址
nginx1 eth1:172.16.1.202
nginx eth0:10.0.0.200 eth1:172.16.1.200

修改NginxWeb服務器配置文件

worker_processes  1;
      events {
          worker_connections  1024;
      }
      http {
          include       mime.types;
          default_type  application/octet-stream;
          sendfile        on;
          keepalive_timeout  65;
          log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                            '$status $body_bytes_sent "$http_referer" '
                            '"$http_user_agent" "$http_x_forwarded_for"';
          server {
              listen       80;
              server_name  www.test.com;
              location / {
                  root   html/;
                  index  index.html index.htm;
              }
                          access_log  logs/access_test.log  main;
          }
          
                }

修改nginx主頁文件

echo "hello" > /application/nginx-1.10.3/html/index.html

修改反向代理服務器配置文件

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;                                                        
    upstream server_pools {
        server 172.16.1.202:80;
    } 
    server {
        listen 80;
                server_name www.test.com;
        location / {
            proxy_pass http://server_pools;
        }
        }
}

修改本地hosts文件

C:\Windows\System32\drivers\etc\hosts

10.0.0.200 www.test.com
  • 啓動nginxWeb服務器以及反向代理服務器

測試

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章