1.创建文件夹目录
cd /usr/local/nginx/conf mkdir vhost /usr/local/nginx/conf/vhost
2.编辑nginx.conf添加如下内容:
include vhost/*.conf;3.mac本地环境配置:sudo vim /etc/hosts
添加192.168.48.11 www.xupan001.com4.在vhost文件夹中创建文件
vim www.xupan001.comt添加如下内容
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;
if ( $query_string ~* ".*[\;'\<\>].*" ) { return 404; }#location = / { root /product/front/mmall_fe/dist/view; index index.html; }
#location ~ .*\.html$ { root /product/front/mmall_fe/dist/view; index index.html; }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; }}
6.浏览器中输入请求转向了tomcat
http://www.xupan001.com:8080/