通过CORS请求反代资源解决跨域问题
在弄反向代理时发现corsproxy这个好东西,可以较为简单解决跨域问题。记录下其用法,以防以后用到。corsproxy是基于Node.js的开源CORS代理工具,使用前需要先安装Nodejs和npm,具体步骤如下(以CentOS为例)。
1. 添加EPEL
软件源,然后安装Nodejs
(npm
会一并安装)。
yum install epel-release yum install -y nodejs
2. 获取安装corsproxy
软件。
npm install -g corsproxy
3. 运行corsproxy
命令激活服务即可开始使用,默认通过http://localhost:1337
反代资源。
假设要反代http://example.com/test.png
这个图片,则使用http://localhost:1337/example.com/test.png
访问。
外网访问不能用localhost,这时可以更改域名和端口,命令如下。
# 更改域名 CORSPROXY_HOST=0.0.0.0 corsproxy # 更改端口 CORSPROXY_PORT=8080 corsproxy
还有两个额外选项。
# 使用调试模式 DEBUG=1 corsproxy # 设置有效负载最大字节(默认为1MB,这里示例设置为10MB) CORSPROXY_MAX_PAYLOAD=10485760 corsproxy
使用时建议开个Screen,不然断开SSH就退出进程了。
ivermectin at tractor supply https://ivermectin.mlsmalta.com/
naltrexone near me https://naltrexoneonline.confrancisyalgomas.com/
order priligy online without prescription https://ddapoxetine.com/
taking viagra with vidalista https://vidalista40mg.mlsmalta.com/
tadalafil tablets 20 mg price in india https://wisig.org/
plaquenil 40 mg https://hydroxychloroquinee.com/
best tadalafil tablets in india https://tadalafil.cleckleyfloors.com/
generic prednisone 20 mg https://prednisone.bvsinfotech.com/
sleep medications for seniors https://edmeds.buszcentrum.com/
sleep medications for seniors https://medpills.bee-rich.com/
can you buy hydroxychloroquine over the counter https://hydroxychloroquine.lm360.us/
can you buy hydroxychloroquine over the counter https://hydroxychloroquine.wisig.org/
cefixime pills at walmart https://ceefexime.co/
tadalafil 20mg pills generic https://cialis.lm360.us/
tadalafil 20mg pills generic https://cialis.adicbc.com/
Hi! I just wanted to ask if you ever have any problems with hackers?
My last blog (wordpress) was hacked and I ended up losing
a few months of hard work due to no back up.
Do you have any solutions to prevent hackers? http://antiibioticsland.com/Amoxil.htm
once daily cialis not working https://cialis.cleckleyfloors.com/