Nginx静态资源分离

Nginx静态资源分离

后端服务部署在192.168.1.1 8080端口
前端静态资源部署在192.168.1.1 8081端口
拥有一个域名:test.com

upstream service {
    server 192.168.1.1:8080;
}

upstream static {
    server 192.168.1.1:8081;
}

server{
    server_name test.com;
    listen 80;
    access_log /data0/www/logs/access_log main;
    error_log  /data/www/logs/error_log;

    location / {
        proxy_pass http://service;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        proxy_pass http://static;
    }

    location ~ .*\.(js|css)?$ {
	   proxy_pass http://static;
    }

    location ~ .*\.(eot|svg|ttf|woff|woff2)$ {
     	proxy_pass http://static;
    }
}

你可能感兴趣的:(Nginx静态资源分离)