Skip to content

Latest commit

 

History

History
82 lines (60 loc) · 2.31 KB

代理.md

File metadata and controls

82 lines (60 loc) · 2.31 KB

内网穿透

一、open-dingtalk/pierced

1、git clone https://github.com/open-dingtalk/pierced.git

2、找到 windows_64 文件,在里面新建 start.bat 脚本,添加代码

backlocal 是域名前缀

9080 是端口号

ding -config=./ding.cfg -subdomain=backlocal 9080
pause

3、双击 start.bat ,这样访问 backlocal.vaiwan.com/xxxxx 都会映射到 http://127.0.0.1:9080/xxxxx

nginx

一、启动

注意不要直接双击nginx.exe,这样会导致修改配置后重启、停止nginx无效,需要手动关闭任务管理器内的所有nginx进程。

在nginx.exe目录,打开命令行工具,用命令 启动/关闭/重启nginx

start nginx 启动nginx

nginx -s reload 修改配置后重新加载生效

nginx -s reopen 重新打开日志文件

nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

二、关闭nginx:

nginx -s stop 快速停止nginx

nginx -s quit 完整有序的停止nginx

代码

# 代理前端请求
# 请求 http://localhost:8080/api => proxy_pass
location /api {
    add_header 'Access-Control-Allow-Origin' $http_origin;
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
    add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
    if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain; charset=utf-8';
        add_header 'Content-Length' 0;
        return 204;
    }
    # 项目根目录
    root   /Users/mac/Documents/dev/xiaofang;
    index  index.html index.htm;
    # 代理地址
    proxy_pass http://192.168.20.221:520/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_connect_timeout 5;
}

package.json

在package.json里添加

"proxy": {
  "/webs/*": {
    "target": "https://github.com/438198602",
    "source": false
  }
}