一、将项目部署到linux下的tomcat上
?二、使用反向代理
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#配置多台服务器
upstream yaya{
server 192.168.200.131:80 weight=7;
server 192.168.200.132:80 weight=2;
server 192.168.200.133:80 weight=1;
}
server {
listen 80;
server_name localhost;
location / {
#代理到服务器133服务器
proxy_pass http://192.168.200.133:8080;
# root html;
#index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
测试访问;
?三、普通的配置动静分离
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#配置多台服务器
upstream yaya{
server 192.168.200.131:80 weight=7;
server 192.168.200.132:80 weight=2;
server 192.168.200.133:80 weight=1;
}
server {
listen 80;
server_name localhost;
location / {
#代理到服务器
proxy_pass http://192.168.200.133:8080;
}
#配置静态文件
location /images {
root html;
index index.html index.htm;
}
location /js {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
?四、使用正则表达式配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#配置多台服务器
upstream yaya{
server 192.168.200.131:80 weight=7;
server 192.168.200.132:80 weight=2;
server 192.168.200.133:80 weight=1;
}
server {
listen 80;
server_name localhost;
location / {
#代理到服务器
proxy_pass http://192.168.200.133:8080;
}
#使用正则表达式
location ~*/(images|js) {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
|