将nginx,java,mysql分别安在不同的服务器上
1.安装openresty, 按照官网操作
#启动openresty
systemctl start openresty.service
2.动静分离服务器
location节点path为resources的访问静态资源路径
location节点其他路径访问动态资源
将静态文件html等放入/usr/local/openresty/nginx/html/resources目录下
修改nginx.conf文件,使http://miaoshaserver/resources/register.html能访问后台静态文件
其他请求访问backend_server中的动态资源。
upstream backend_server{
server 127.0.0.1:8090 weight=1;
server 192.168.31.65:8090 weight=1;
}
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location /resources/ { alias /usr/local/openresty/nginx/html/resources/; index index.html index.htm; }
location / {
proxy_pass http://backend_server/;
proxy_set_header Host $http_host:$proxy_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarder_for;
}
重启nginx [root@iZbp1dtm752cu7uoi7cj5fZ nginx]# sbin/nginx -s reload
查看启动是否正常 [root@iZbp1dtm752cu7uoi7cj5fZ logs]# tail -f error.log