1vue项目只规定部分product下的页面配置移动端(不正确,供参考??):问题是-- /kj/#/product/这个径找不到:nginx location 找不到vue的代理路径找不到
location @router {
#默认PC端访问内容
set $flag 0;
#如果是手机移动端访问内容
if ($http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT-)|(SonyEricsson)|(NEC-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC-)|(SED-)|(EMOL-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)") {
set $flag "${flag}1";
}
if ($flag = "01"){
root html/kj_wap;
rewrite ^.*$ /index.html last;
}
}
location /kj/#/product/ {
try_files $uri $uri/ @router;
index index.html;
}
2正常
location /kj/ {
#默认PC端访问内容
set $flag 0;
#如果是手机移动端访问内容
if ($http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT-)|(SonyEricsson)|(NEC-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC-)|(SED-)|(EMOL-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)") {
set $flag "${flag}1";
}
if ($flag = "01"){
root html/kj_wap;
}
# try_files $uri $uri/ /index.html;
}
image.png
image.png
打印nginx配置参数
image.png
检查nginx并更新:
/usr/local/nginx/sbin/nginx -t //检查
/usr/local/nginx/sbin/nginx -s reload //更新
user cnki;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#add_header Content-Security-Policy "default-src 'self' http://* https://cnki-1258158163.cos.ap-beijing.myqcloud.com https://cpma.cnki.net http://1258158163.vod2.myqcloud.com https://hm.baidu.com https://api.map.baidu.com http://static.tieba.baidu.com https://*.bdimg.com http://*:8082 data:;script-src 'self' http://* 'unsafe-inline' 'unsafe-eval';style-src 'self' http://* 'unsafe-inline';connect-src 'self' http://* http://*:5555 http://*:8082 http://*:8083 http://*:8089 http://*:8086 http://*:8020 http://*:8800 http://*:8098 http://*:9089 http://*:8181 http://*:8000 http://1258158163.vod2.myqcloud.com 'unsafe-inline';font-src 'self' data: http://at.alicdn.com;";
#add_header X-Content-Type-Options "nosniff";
#add_header X-XSS-Protection "1; mode=block";
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$upstream_addr" "$upstream_response_time"';
access_log logs/main-access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 16000;
send_timeout 60m;
client_body_timeout 60m;
client_header_timeout 60m;
#default 5s
#lingering_timeout 60;
#default 30s
#resolver_timeout 180;
proxy_ignore_client_abort on;
proxy_connect_timeout 18000;
proxy_read_timeout 18000;
proxy_send_timeout 18000;
proxy_buffering off;
proxy_buffer_size 4k;
proxy_buffers 8 1m;
proxy_busy_buffers_size 2m;
proxy_max_temp_file_size 0;
client_max_body_size 500M;
#gzip on;
#upstream authCluster {
#ip_hash;
#server 10.120.150.147:8081;
#}
upstream webCluster {
#ip_hash;
server 10.120.150.147:8089;
}
upstream managerCluster {
#ip_hash;
server 10.120.150.147:8088;
}
upstream knmanagerCluster {
#ip_hash;
server 10.120.150.147:8081;
}
upstream knmanager1Cluster {
#ip_hash;
server 10.120.150.147:8086;
}
upstream knwebCluster {
#ip_hash;
server 10.120.150.147:8082;
}
upstream ruoyiCluster {
#ip_hash;
server 10.120.150.147:8083;
}
upstream videoCluster {
#ip_hash;
server 10.120.150.147:8087;
}
upstream mobileCluster {
#ip_hash;
server 10.120.150.147:9089;
}
upstream checkerCluster {
#ip_hash;
server 10.120.150.147:8181;
}
server {
listen 80;
server_name 10.120.150.147;
location / {
root html;
}
#location /auth/ {
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# rewrite "^/auth/(.*)$" /$1 break;
# proxy_pass http://authCluster;
# }
location /webapi/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
rewrite "^/webapi/(.*)$" /$1 break;
proxy_pass http://webCluster;
}
location /managerapi/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
rewrite "^/managerapi/(.*)$" /$1 break;
proxy_pass http://managerCluster;
}
location /knmarket-manage/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#rewrite "^/(.*)$" /$1 break;
proxy_pass http://knmanagerCluster;
}
location /knmarket-manage-api/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#rewrite "^/(.*)$" /$1 break;
proxy_pass http://knmanager1Cluster;
}
location /knmarket-web/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#rewrite "^/(.*)$" /$1 break;
proxy_pass http://knwebCluster;
}
location /authapi/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
rewrite "^/authapi/(.*)$" /$1 break;
proxy_pass http://ruoyiCluster;
}
location /video-web/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#rewrite "^/(.*)$" /$1 break;
proxy_pass http://videoCluster;
}
location /mobile-web/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#rewrite "^/(.*)$" /$1 break;
proxy_pass http://mobileCluster;
}
location /data-checker/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#rewrite "^/(.*)$" /$1 break;
proxy_pass http://checkerCluster;
}
location = /static/ {
return 404;
}
location = /download/ {
return 404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
网友评论