default.conf
885 Bytes
server {
# 监听端口
listen 80;
server_name localhost;
location / {
# 编译后代码文件位置
root /usr/share/nginx/html;
# 编译后代码访问页
index index.html index.htm;
# 解决URL栏直接访问404问题
try_files $uri $uri/ /index.html;
}
# 反向代理
# /api/ 为url拦截标志 如 localhost/api/xxx 请求会被拦截 ,最后得到请求地址为 http://server/api/xxx
location /api/ {
# 实际的访问地址
# proxy_pass http://127.0.0.1:9000/;
}
# 开启GZip压缩
gzip on;
gzip_disable "MSIE [1-6]\.";
gzip_proxied any;
gzip_min_length 1k;
gzip_comp_level 5;
gzip_types text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
}