通过CORS请求反代资源解决跨域问题

Kevin 杂记 1,071 次浏览 38条评论

在弄反向代理时发现corsproxy这个好东西,可以较为简单解决跨域问题。记录下其用法,以防以后用到。corsproxy是基于Node.js的开源CORS代理工具,使用前需要先安装Nodejs和npm,具体步骤如下(以CentOS为例)。

1. 添加EPEL软件源,然后安装Nodejsnpm会一并安装)。

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就退出进程了。

评论列表

  1. #1

    ivermectin at tractor supply https://ivermectin.mlsmalta.com/

  2. #2

    naltrexone near me https://naltrexoneonline.confrancisyalgomas.com/

  3. #3

    order priligy online without prescription https://ddapoxetine.com/

  4. #4

    taking viagra with vidalista https://vidalista40mg.mlsmalta.com/

  5. #5

    tadalafil tablets 20 mg price in india https://wisig.org/

  6. #6

    plaquenil 40 mg https://hydroxychloroquinee.com/

  7. #7

    best tadalafil tablets in india https://tadalafil.cleckleyfloors.com/

  8. #8

    generic prednisone 20 mg https://prednisone.bvsinfotech.com/

  9. #9

    sleep medications for seniors https://edmeds.buszcentrum.com/

  10. #10

    sleep medications for seniors https://medpills.bee-rich.com/

  11. #11

    can you buy hydroxychloroquine over the counter https://hydroxychloroquine.lm360.us/

  12. #12

    can you buy hydroxychloroquine over the counter https://hydroxychloroquine.wisig.org/

  13. #13

    cefixime pills at walmart https://ceefexime.co/

  14. #14

    tadalafil 20mg pills generic https://cialis.lm360.us/

  15. #15

    tadalafil 20mg pills generic https://cialis.adicbc.com/

  16. #16

    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

  17. #17

    once daily cialis not working https://cialis.cleckleyfloors.com/

  18. #18

    Your style is really unique in comparison to other people
    I have read stuff from. Thank you for posting when you’ve got
    the opportunity, Guess I’ll just bookmark this site. http://herreramedical.org/hydroxychloroquine

  19. #19

    lancet hydroxychloroquine study http://hydroxychloroquined.online/

  20. #20

    buy hydroxychloroquine online https://hydroxychloroquinex.com/

  21. #21

    buy tadalafil us https://elitadalafill.com/ tadalafil pills

  22. #22

    tadalafil 20mg – ambrisentan and tadalafil buy tadalafil online reddit

  23. #23

    where to buy viagra viagra price
    buy generic 100mg viagra online

  24. #24

    vardenafil buy https://vegavardenafil.com/ vardenafil

  25. #25

    sildenafil cream in india https://eunicesildenafilcitrate.com/ sildenafil citrate 100mg tab

  26. #26

    cheap ed pills in mexico buy ed pills from canada
    cheap ed pills from india

  27. #27

    cheap ed pills cheap ed pills from canada
    cheap ed pills

  28. #28

    Noqyru – stromectol buy uk Zlwdko olnboc

  29. #29

    cheap ed pills from india cheap ed pills in mexico
    cheap ed pills from india

  30. #30

    Sdqlcj – cialis sans ordonnace Rfycuh zvluqz

  31. #31

    how much alprostadil vials https://alprostadildrugs.com/ alprostadil cream cost

  32. #32

    Nfzhbv – furosempi.com Zfjcix qmxzhq

  33. #33

    Dhxlbz – online tadalafil 20mg Npzbit zigqhe

  34. #34

    Buozcl – write a personal statement Yyknwo koflcj

  35. #35

    Aukzns – buy generic viagra online no prescription Mjcnru vjgnes

  36. #36

    tetracycline generic: augmentin price
    order chloramphenicol

  37. #37

    Gkseef – narrative essay Dwwgzj iykxpv

  38. #38

    best india pharmacy: india pharmacy mail order generic pills india

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。