upstream redislock{
server 192.168.3.197:8001;
server 192.168.3.197:8002;
}
server {
listen 80;
server_name test;
location / {
#允许跨域请求的域,*代表所有
add_header 'Access-Control-Allow-0rigin' *;
#允许带上cookie请求
add_header 'Access-Control-Allow-Credentials' 'true';
#允许请求的方法,比如GET/POST/PUT/DELETE
add_header 'Access-Control-Allow-Methods' *;
#允许请求的header
add_header 'Access-Control-Allow-Headers' *;
proxy_pass http://redislock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
firewall-cmd --zone=public --add-port=80/tcp --permanent 暴露80端口
systemctl restart firewalld.service 防火墙重启
./nginx -t 检查配置文件
./nginx -s stop 停止当前nginx服务
ps -ef|grep nginx 查看当前运行的nginx服务
./nginx 启动当前nginx服务