下载nginx
放到服务器中
解压
安装依赖:
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
使用默认配置:cd到解压文件夹下运行 ./configure
编译:make
安装:make install
cd到:/usr/local/nginx/conf
编辑文件:vi nginx.conf
内容:
server{
listen 8082;
server_name 39.100.44.244;
location / {
root /home/data/www/prod-culture-manager-web/dist;
index index.html index.htm;
try_files $uri $uri/ @router;
}
location @router {
rewrite ^.*$ /index.html last;
}
location ^~/api/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://172.26.215.249:8092/;
}
}
nginx命令:
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
启动nginx尝试访问
放开80端口:firewall-cmd —zone=public —add-port=80/tcp —permanent
重启防火墙:systemctl restart firewalld