1.建立文件夾目錄
cd /usr/local/nginx/conf
mkdir vhost
/usr/local/nginx/conf/vhostphp
2.編輯nginx.conf添加以下內容:
include vhost/*.conf;css
3.mac本地環境配置:sudo vim /etc/hosts
添加192.168.48.11 www.xupan001.comhtml
4.在vhost文件夾中建立文件
vim www.xupan001.comnginx
t添加以下內容
vim
server {
listen 80;
autoindex on;
server_name www.xupan001.com;
access_log /usr/local/nginx/logs/access.log combined;瀏覽器
index index.html index.htm index.jsp index.php;tomcat
if ( $query_string ~* ".*[\;'\<\>].*" ) {
return 404;
}jsp
#location = / { root /product/front/mmall_fe/dist/view; index index.html; }
#location ~ .*\.html$ { root /product/front/mmall_fe/dist/view; index index.html; } server
location / {
proxy_pass http://127.0.0.1:8080/;
add_header Access-Control-Allow-Origin *;
}
#location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)
#$ { proxy_pass http://127.0.0.1:8080; expires 30d; }
#location ~ .*\.(js|css)?$ { proxy_pass http://127.0.0.1:8080; expires 7d; } htm
}
6.瀏覽器中輸入請求轉向了tomcat
http://www.xupan001.com:8080/