zoukankan      html  css  js  c++  java
  • vue部署服务器nginx代理配置删除多余/api部分

    vue部署服务器后,请求地址统一配置加了‘/api’前缀

    要访问三方接口地址:http://10.10.10.25:8080/IntellLinkPf/GetChainSummary

       vue的请求多了/api:http://10.10.10.25:8080/api/IntellLinkPf/GetChainSummary

    修改nginx代理配置解决:

    #user  nobody;
    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  5024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
        #gzip  on;
    
        server {
        listen      8080;
        server_name 10.10.10.25;
        #rewrite_log on; 重写url记录日志
        #error_log  logs/test.log debug;
    
        #代理方式
        location /api/IntellLinkPf/ {
               proxy_pass http://202.14.69.26:18720/IntellLinkPf/; #最后增加'/IntellLinkPf/',代理后地址移除了'/api'
            }
            
        #重写方式
        location /api/IntellLinkPf/ {
            rewrite /api/(.*) /$1 break; #移除了'/api',$1表示正则中括号匹配到的串
            proxy_pass http://202.14.69.26:18720; 
            }
    
        location /QCAPI/ {
               proxy_pass http://10.10.10.25:50095;
            }
    
        location /render/ {
               proxy_pass http://119.123.241.169:9035;
            }
    
        location /{
           proxy_pass  http://10.10.10.25:8166;
        }
        }
    
    }

    参考:https://www.cnblogs.com/lixiuran/p/5515583.html

  • 相关阅读:
    v-date
    文字在图片上
    v-生命周期
    彭博接口分类
    如何指定vim 的查找是从上往下还是从下往上[z]
    查看linux版本
    git web找不到new project解决方法
    比特币运行原理[z]
    [Z]haproxy+keepalived高可用群集
    blockchain good article
  • 原文地址:https://www.cnblogs.com/glory0727/p/13546323.html
Copyright © 2011-2022 走看看