赞
踩
- [root@host1 conf.d]# pwd
- /usr/local/nginx/conf.d
[root@host1 conf.d]# vim test1.conf
这里设置监听端口为8080
- server {
- resolver 114.114.114.114;
- listen 8080;
- location / {
- proxy_pass http://$http_host$request_uri;
- }
- }
host2 和 localhost 安装httpd
localhost 设置为仅主机模式添加ip 192.168.91.131
- [root@localhost ~]# echo "this is a test" > /var/www/html/index.html
- [root@localhost ~]# systemctl start httpd
- [root@localhost ~]# systemctl stop firewalld
- [root@localhost ~]# setenforce 0
这里设置监听端口为8800
[root@host1 conf.d]# vim test2.conf
- server {
- listen 8800;
- server_name localhost;
- location /{
- proxy_pass http://192.168.91.131;
- }
- }
如下:测试语法无误
重启nginx
此台电脑需要关掉防火墙并设置selinux
curl 8800 端口
host2、host3为两台web服务器
均安装epel(rhel7)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
使用yum下载nginx
yum install nginx -y
- mkdir /usr/share/nginx/html/{www,bbs}/logs -p
-
- cd /etc/nginx/conf.d
vim vhost.conf
- server {
- listen 80;
- server_name bbs.yunjisuan.com;
- location / {
- root /usr/share/nginx/html/bbs;
- index index.html index.htm;
- }
- access_log /usr/share/nginx/html/bbs/logs/access_bbs.log main;
- }
- server {
- listen 80;
- server_name www.yunjisuan.com;
- location / {
- root /usr/share/nginx/html/www;
- index index.html index.htm;
- }
- access_log /usr/share/nginx/html/www/logs/access_www.log main;
- }
- echo "`hostname -I `www" > /usr/share/nginx/html/www/index.html
- echo "`hostname -I `www" > /usr/share/nginx/html/bbs/index.html
- systemctl stop firewalld
- setenforce 0
- systemctl start nginx
-
- 检查语法
- nginx -t
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。