运维开发网

Nginx配置vue代码 访问正常 刷新404解决方案

运维开发网 https://www.qedev.com 2021-02-24 12:41 出处:51CTO 作者:hanye韩也
Nginx配置vue-element-admin代码 访问正常 刷新404解决方案

配置vue-element-admin

 # 克隆项目
 git clone https://github.com/PanJiaChen/vue-element-admin.git
 # 进入项目目录
 cd vue-element-admin
 # 安装依赖
 npm install
 # 建议不要用 cnpm 安装 会有各种诡异的bug 可以通过如下操作解决 npm 下载速度慢的问题
 npm install --registry=https://registry.npm.taobao.org
 # 本地开发 启动项目
 npm run dev

配置nginx

server {
 listen 80;
 server_name admin.hanye.com;
 charset utf-8;
 include deny_host.conf;
 access_log /data/wwwlogs/Admin_access_nginx.log main;
 error_log  /data/wwwlogs/Admin_error_nginx.log;

 location / {
   root /home/erp/WEB/admin/dist;
   try_files $uri $uri/ /index.html; #此处解决刷新页面出现404的问题
   index index.html index.htm;
 }
     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
        expires 30d;
        access_log off;
        }
     location ~ .*\.(js|css)?$ {
        expires 7d;
        access_log off;
       } 
  }
配置deny_host.conf
deny 23.226.61.213;
deny 212.237.59.163;
deny 116.90.237.142;
deny 63.243.14.117;
deny 54.175.125.253;
deny 63.243.14.117;
deny 27.133.155.194;
deny 212.237.54.44;
deny 191.96.249.80;
deny 200.122.128.162;
deny 138.121.164.8;
deny 159.8.217.214;
deny    69.55.29.253;
deny 203.24.188.59;
deny 169.56.89.210;
deny 54.175.125.253;
deny 35.186.205.6;
deny 23.226.61.213;
deny 4.215.176.145;
deny 60.255.187.126;
deny 120.24.40.11;
deny 58.218.213.134;
deny 173.208.149.138;
deny 94.23.210.41;
deny 218.26.72.34;
deny 218.2.0.185;
deny 62.210.209.201;
deny 123.57.148.247;
deny 58.30.96.142;
deny 118.89.58.183;
deny 118.184.40.225;
deny 125.7.231.122;
deny 222.186.172.54;
deny 58.30.96.137;
deny 190.60.198.194;
deny 37.59.0.139;
deny 221.0.168.96;
deny 35.194.65.252;
deny 115.231.218.43;
deny 162.209.168.8;
deny 136.197.150.139;
deny 35.184.134.121;
deny 71.79.200.189;
deny 114.112.245.106;
deny 19.174.117.65;
deny 101.178.20.14;
deny 11.206.34.126;
deny 226.101.95.225;
deny 45.92.85.129;
deny 23.235.173.95;
deny 47.92.155.104;
deny 112.133.220.188;
deny 144.217.105.158;
deny 118.244.237.33;
deny 218.2.22.147;
deny 132.228.154.57;
deny 204.129.61.100;
deny 115.231.218.43;
deny 221.231.6.91;
deny 182.254.132.26;
deny 132.228.154.57;
deny 101.178.20.14;
deny 136.197.150.139;
deny 204.129.61.100;
deny 71.79.200.189;
deny 114.112.245.106;
deny 226.101.95.225;
deny 23.235.173.95;
deny 47.92.155.104;
deny 11.206.34.126;
deny 144.217.105.158;
deny 112.133.220.188;
deny 45.92.85.129;
deny 118.244.237.33;
deny 221.231.6.91;
deny 182.254.132.26;
deny 19.174.117.65;
deny 218.2.22.147;
deny 221.0.168.96;
deny 35.194.65.252;
deny 115.231.218.43;
deny 162.209.168.8;
deny 35.184.134.121;
deny 115.231.218.43;
deny 218.61.30.235;
deny 203.158.22.39;
deny 80.211.238.38;
deny 201.18.21.212;
deny 218.58.14.130;
deny 87.11.123.100;
deny 183.136.188.116;
deny 209.92.176.156;
deny 149.56.143.173;
deny 186.62.103.74;
deny 113.109.113.51;
deny 186.129.243.139;
deny 128.199.165.114;
deny 60.2.76.134;
deny 51.15.195.131;
deny 45.77.152.129;
deny 47.93.12.160;
deny 51.15.203.67;
deny 51.15.217.219;
deny 114.119.41.9;
deny 222.160.150.198;
deny 190.49.121.130;
deny 177.21.228.195;
deny 90.151.149.124;
deny 51.15.221.135;
deny 139.170.248.251;
deny 128.199.190.33;
deny 207.61.255.12;
deny 185.145.131.16;
deny 51.15.204.9;
deny 77.73.67.189;
deny 136.179.6.36;
deny 111.206.169.173;
deny 222.73.12.22;
deny 119.253.248.211;
deny 80.211.238.78;
deny 163.172.112.193;
deny 51.15.209.6;
deny 115.225.160.128;
deny 41.223.182.216;
deny 82.200.168.101;
deny 115.60.186.254;
deny 111.144.139.0;
deny 221.229.204.124;
deny 34.200.238.202;
deny 180.97.190.79;
deny 185.92.73.108;
deny 117.27.159.145;
deny 123.249.35.138;
deny 118.189.145.230;
deny 150.70.188.167;
deny 209.210.183.140;
deny 123.249.35.138;
deny 140.240.30.67;
deny 54.72.102.1;
deny 43.248.103.26;
deny 202.100.214.104;
deny 201.178.152.41;
deny 104.131.109.149;
deny 218.108.158.238;
deny 115.215.55.25;
deny 78.245.236.138;
deny 42.115.142.151;
deny 201.177.161.121;
deny 60.165.208.28;
deny 121.234.56.44;
deny 60.239.42.29;
deny 37.76.148.15;
deny 121.194.2.252;
deny 46.17.100.30;
deny 103.207.39.154;
deny 220.248.123.190;
deny 123.123.255.50;
deny 202.96.25.88;
deny 185.165.29.198;
deny 60.174.195.41;
deny 212.237.37.211;
deny 220.191.255.198;
deny 96.91.204.122;
deny 159.203.42.152;
deny 103.85.23.24;
deny 180.76.139.176;
deny 103.60.221.239;
deny 202.53.138.23;
######
deny 101.107.11.84;
deny 101.29.118.14;
deny 106.111.222.218;
deny 110.184.163.240;
deny 112.192.144.162;
deny 112.194.90.218;
deny 112.195.155.239;
deny 112.237.188.252;
deny 112.67.181.132;
deny 113.75.0.190;
deny 113.85.77.168;
deny 114.104.135.176;
deny 115.213.235.75;
deny 115.215.6.67;
deny 115.217.164.103;
deny 115.217.164.107;
deny 115.217.165.54;
deny 115.217.165.56;
deny 118.118.199.172;
deny 119.140.160.129;
deny 119.250.9.210;
deny 119.5.1.37;
deny 121.20.5.8;
deny 121.232.148.220;
deny 122.231.185.87;
deny 122.239.143.197;
deny 122.245.13.7;
deny 122.4.50.235;
deny 123.134.237.161;
deny 123.146.68.192;
deny 123.163.153.201;
deny 123.163.167.132;
deny 123.163.178.194;
deny 125.105.111.246;
deny 125.106.189.65;
deny 125.111.117.133;
deny 125.111.117.203;
deny 125.111.118.103;
deny 125.111.118.185;
deny 125.121.6.109;
deny 125.123.136.211;
deny 125.123.136.224;
deny 125.87.101.12;
deny 140.250.189.205;
deny 140.255.43.187;
deny 171.12.87.240;
deny 180.116.211.132;
deny 180.141.130.18;
deny 183.147.19.189;
deny 183.149.89.205;
deny 183.159.235.127;
deny 183.164.235.175;
deny 223.104.10.8;
deny 223.145.229.211;
deny 223.156.197.238;
deny 223.156.199.119;
deny 27.157.3.91;
deny 27.221.193.235;
deny 27.31.102.199;
deny 36.56.79.172;
deny 52.80.164.236;
deny 58.255.4.190;
deny 58.47.35.146;
deny 60.175.212.125;
deny 61.151.178.166;
deny 66.249.79.48;
deny 101.20.203.221;
deny 110.249.201.14;
deny 110.251.237.78;
deny 113.76.134.234;
deny 114.104.184.23;
deny 115.202.142.15;
deny 115.215.56.57;
deny 117.90.137.239;
deny 117.93.83.90;
deny 121.232.199.18;
deny 121.234.244.24;
deny 121.236.124.13;
deny 122.190.146.17;
deny 123.134.222.17;
deny 123.151.148.54;
deny 123.151.148.56;
deny 123.151.148.57;
deny 123.151.76.158;
deny 123.151.77.71;
deny 124.94.197.168;
deny 125.111.117.94;
deny 125.111.119.10;
deny 125.113.112.41;
deny 125.69.91.101;
deny 125.72.106.141;
deny 125.87.106.21;
deny 183.128.64.57;
deny 218.73.128.18;
deny 218.73.143.100;
deny 220.178.145.85;
deny 222.95.190.183;
deny 223.199.215.12;
deny 223.242.128.10;
deny 223.242.248.10;
deny 27.202.62.212;
deny 27.40.132.213;
deny 49.85.248.190;
deny 49.88.93.155;
deny 58.19.62.211;
deny 58.212.58.113;
deny 59.49.191.249;
deny 61.148.245.141;
deny 66.249.79.17;
if ($http_referer ~* "tj.cn") {
  return 403;
}

if ($http_user_agent ~ "OtherSpider|Baiduspider|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot|^$" )

{
     return 403;
}

if ($http_user_agent ~* (Scrapy|HttpClient))
{
     return 403;
}

    location ~*(\/\/.*$) {
     return 403;
   }
if ($http_referer ~ .*.online.tj.cn) {
    return 403;
}
if ($http_referer ~* "www188.asd.tj.cn") {
    return 403;
}

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号