【Nginx】 nginx | 静态资源配置 | nginx报错zero size shared memory zone one

4 篇文章 0 订阅

1、静态资源(html)

server {
        listen       80;
        root /usr/share/nginx/html;
        index index.html;
       
        location / {
             root /usr/share/nginx/html;
		     try_files $uri $uri/ /index.html;
        }
}

说明1: 未配置域名,仅通过ip访问

说明2: root 指明静态资源路径

说明3: try_files 解决刷新404

2、多个URI,不同路径

server {
        listen       8080;
        server_name  localhost;
        index index.html;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /h5 {
            root   /opt/apache-tomcat-8.5.64/webapps;
            index  index.html;
            #try_files $uri $uri/ /index.html;
        }

        location / {
            root   /home/webapps/jeeplus/dist;
            index  index.html;
            #try_files $uri $uri/ /index.html;
        }
}

说明1: 不同静态文件,不同URI映射不同路径

说明2: 访问连接

http://127.0.0.1:8080/h5/index.html

对应的路径为:

真实路径携带URI的h5,需留意,不然访问会404

~~

3、vue打包后

1)配置

server {
     listen 80;
    server_name localhost 192.168.0.1;
    # gzip config
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";

    location / {
        root /var/lib/jenkins/workspace/hg-demo/dist;
        index index.html;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_send_timeout      30m;
        proxy_read_timeout      30m;
        client_max_body_size    100m;
        try_files $uri $uri/ /index.html;
    }
   }

~~

4、nginx报错zero size shared memory zone one

1)注释掉: limit_conn

2)原因: 没有nginx未支持此模块【http_limit_conn_zone】

~~

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值