欢迎光临
我的个人博客

Nginx添加部署多个server

1.增加nginx权限

vi /etc/nginx/nginx.conf

user nginx; 改为 user root;

2.禁用selinux

vi /etc/selinux/config  

改成SELINUX=disabled

3.站点工作目录

mkdir -p /usr/share/nginx/blade

4.创建include文件blade.conf

vi /etc/nginx/conf.d/blade.conf
server {
        listen       80;
        server_name  blade;
        root         /usr/share/nginx/blade;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

5.增加反向代理

 server {
        listen       80;
        server_name  blade;
        root         /usr/share/nginx/blade;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
		

        }

	location /auth/web {
		proxy_pass http://demo.springblade.org/auth/web;
		add_header Cache-Control no-store;
	}

	location /api/web {
                proxy_pass http://demo.springblade.org/api/web;
                add_header Cache-Control no-store;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

6.重启nginx服务

systemctl restart nginx  

7.如果启动失败需要检查端口的占用情况

netstat -tunlp | grep 端口号

转载请标明来源:ibear » Nginx添加部署多个server

分享到:更多 ()

Where there is a will there is a way

我的新浪微博