nginx:
location / {
root /home/web2_root;
proxy_pass http://127.0.0.1:8080/web/;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
node.js:
const express = require('express');
const proxy = require('http-proxy-middleware');
const app = express();
app.use('/static', express.static(`${__dirname}/static`));
app.use('/v2', proxy({
target: 'http://api.douban.com',
changeOrigin: true,
}));
app.get('/*', (req, res) => {
res.sendFile(`${__dirname}/index.html`);
});
app.listen(8000);