找回密碼
 註冊
搜索
查看: 3290|回復: 0

安裝 cors-anywhere "https"

[複製鏈接]
發表於 2018-3-19 17:10:23 | 顯示全部樓層 |閱讀模式

如果需要能跑https cors,則要利用letsencrypt-auto產生SSL key
./letsencrypt-auto certonly -d cors.example.com --manual --preferred-challenges dns
#vi cors_anywhere_https.js
加入以下內容
var host = process.env.HOST || '0.0.0.0';
var port = process.env.PORT || 8080;
var fs = require('fs');
var originBlacklist = parseEnvList(process.env.CORSANYWHERE_BLACKLIST);
var originWhitelist = parseEnvList(process.env.CORSANYWHERE_WHITELIST);
function parseEnvList(env) {
  if (!env) {
    return [];
  }
  return env.split(',');
}
var checkRateLimit = require('./lib/rate-limit')(process.env.CORSANYWHERE_RATELIMIT);
var cors_proxy = require('./lib/cors-anywhere');
cors_proxy.createServer({
    httpsOptions: {
        key: fs.readFileSync('/etc/letsencrypt/live/cors.example.com/privkey.pem'),
        cert: fs.readFileSync('/etc/letsencrypt/live/cors.example.com/fullchain.pem')
    },
}).listen(port, host, function() {
  console.log('Running CORS Anywhere on ' + host + ':' + port);
});

CentOS - Run as Service
#npm install pm2@latest -g
#npm install
#pm2 start cors_anywhere_https.js
#pm2 show cors_anywhere_https
#pm2 startup systemd


Reference:
How to setup for https
https://github.com/Rob--W/cors-anywhere/issues/74
https://serverfault.com/question ... hallenge-validation
https://www.digitalocean.com/com ... duction-on-centos-7
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|彩色筆小沛的知識庫

GMT+8, 2024-12-22 03:00 , Processed in 0.024975 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表