我想把我的快递后端从http://localhost:3000/到http://localhost/backend,我该怎么做?
可以使用nginx
的服务器块
nginx.conf
:
server {
listen 80;
location / {
proxy_pass http://localhost:3000/;
}
}
app.ts
:
import express from 'express';
const app = express();
app.get('/backend', (req, res) => {
res.sendStatus(200);
});
app.listen(3000, () => console.log('server started at port 3000'));
测试:
^ curl http://localhost/backend
OK%