【发布时间】:2018-12-21 16:32:44
【问题描述】:
我为我的项目创建了 AWS 实例并安装了 Nginx 服务器。现在对于 Angular,我创建 ang.conf,对于节点,在 site-available 中创建 node.conf 文件。分享我的 conf 文件
ang.conf
server {
listen 80;
server_name IP;
location / {
root project_path;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 403 /403.html;
# To allow POST on static pages
error_page 405 =200 $uri;
}
node.conf
server {
listen 3004;
server_name IP;
location / {
proxy_pass http://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;
}
}
我的节点服务器工作正常。我可以将api 到postman 与端口一起使用,例如http://MY_YP:3000。但是在角站点中,当我转到浏览器并转到 login 页面并单击提交按钮时,未连接到 node js 服务器。当我在网络中检查我的响应时,它会像这样返回。
Response
HTTP/1.1 200 OK
ETag: W/"5b486d9c-848"
Content-Type: text/html
Date: Fri, 13 Jul 2018 09:56:38 GMT
Last-Modified: Fri, 13 Jul 2018 09:15:08 GMT
Server: nginx/1.10.3 (Ubuntu)
Connection: keep-alive
Content-Encoding: gzip
Transfer-Encoding: Identity
我不知道这段代码有什么问题。请建议我如何处理。
【问题讨论】:
-
您分享的回复是在 Angular 应用程序(浏览器的控制台)上还是在邮递员上?
-
@DushyantBangal 这个浏览器控制台
标签: node.js angular express nginx nginx-location