nginx.cnf配置
~~~
upstream tomcat_server {
server 10.25.39.131:8080;
server 10.25.39.132:8080;
}
server {
listen 80;
server_name www.wxvote.com;
##設置歡迎頁
location = / {
root WeiXinVote;
index index.html;
}
location ~* \.(html|css|js|gif|jpg|jpeg|mp4|ttf|eot|svg|woff)$ {
root WeiXinVote;
}
##注意:前面必須加^~ ,提升配置的優先級。
location ^~ /upload/
{
proxy_pass http://tomcat_server/upload/;
proxy_set_header Host $host;
}
location /
{
proxy_pass http://tomcat_server/WeiXinVote/;
proxy_set_header Host $host;
}
}
~~~
注意,在后臺代碼中,請求重定向會加上工程名,redirect:/WeiXinVote/xx,
Spring MVC環境下,Spring MVC會自動添加工程名,導致nginx環境下,訪問路徑出錯。
解決方案:部署項目的時候,不要工程名。
部署2套工程的動靜分析,根據域名反向代理
~~~
upstream tomcat_server {
server 10.25.39.131:8080;
server 10.25.39.132:8080;
}
server {
listen 80;
server_name www.wxvote.com;
location ~* \.(html|css|js|gif|jpg|jpeg|mp4)$ {
root WeiXinVote;
}
location /
{
proxy_pass http://tomcat_server/WeiXinVote/;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name www.neusoft.com;
location ~* \.(html|css|js|gif|jpg|jpeg|mp4)$ {
root neusoft;
}
location / {
proxy_pass http://tomcat_server/neusoft/;
proxy_set_header Host $host;
}
}
~~~
- 第一章 Linux
- 1. Linux安裝和網絡配置
- 2. Linux基本命令
- 3. Xshell和winscp
- 4. VIM編輯器
- 5. 安裝軟件
- 5.1 安裝JDK
- 5.2 安裝TOMCAT
- 5.3 安裝MySql
- 5.4 安裝Nginx
- 5.5 部署工程
- 第二章 Nginx
- 1. 安裝Nginx
- 2. 配置Nginx
- 2.1 配置靜態服務器
- 2.2 配置反向代理
- 2.3 配置負載均衡
- 2.4 配置動靜分離
- 2.5 跨域訪問
- 第三章 Redis
- 1. 安裝Redis
- 2. JAVA操作Redis
- 3. Redis事務
- 4. Redis持久化
- 5. 主從復制和集群
- 6. Redis實現Session共享
- 第四章 MySQL主從復制
- 4.1 MyCat安裝
- 4.2 MySQL主從復制
- 4.3MySQL讀寫分離
- 第五章 ActiveMQ
- 5.1 Queue
- 5.2 Topic
- 第六章 FastDFS圖片服務器
- 第七章