我想在同一服务器上同时提供Angular应用程序和Nodejs API。 Angular前端应位于example.com和api中,位于example.com/api
server {
server_name example.com www.example.com;
location /api/ {
proxy_pass http://private_ip:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
root /var/www/html; #angular app here
index index.html;
try_files $uri $uri/ /index.html;
}
}
当我喜欢在example.com而不是example.com/api
中加载应用程序时