ubuntu - .net core mvc API 使用 NGINX 反向代理部署在 UBUNTU 上,POST 请求抛出 404 错误
问题描述
我创建了一个 .net 核心 API,它又在 .net 核心 Web 应用程序中使用。它们使用其 IP 和自定义端口部署在 ubuntu 机器上。API 和 webapp 的服务文件已粘贴在下面。当我尝试通过网络应用程序发布数据时,它会给出错误“404”,指出找不到发布功能。
API 和 webApp 都通过 IP 托管,但是当它们使用 localhost 托管时,POST 请求可以正常工作。这没有帮助,因为这些将通过 IP 本身托管。
在下面发布我的文件,请帮助。
server {
listen 6002;
server_name attendanceapp;
root /home/arun/net-core/Publish/AttendanceModule/AttendanceAPI;
location /attendancepp/{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://192.168.0.27:6002;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "";
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type';
add_header 'Content-Type' 'application/json';
}
}
server {
listen 192.168.0.27:6001;
server_name attendancepi;
root /home/arun/net-core/Publish/AttendanceModule/AttendanceAPI;
location /attendanceapi/ {
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection $http_connection;
proxy_cache_bypass $http_upgrade;
}
}
解决方案
推荐阅读
- arrays - 使用 LAMBDA 递归函数从字符串中删除所有数字
- angular - BrowserTestingModule 和 BrowserDynamicTestingModule 的用途
- c# - 将文本时间转换为日期时间变量c#
- code-snippets - 在自定义 Emmet 片段中重复光标文本
- python - 在 python 中将 2x16 数据帧转换为 4 x 4 矩阵
- python - Django表单提交不刷新
- javascript - 获取天气预报 api javascript 时出现未定义的错误
- python - Python 请求在 __doPostBack 之后获得 __VIEWSTATE 和 __EVENTVALIDATION
- python - 在 Jupyter 笔记本上使用 read_csv 时找不到文件错误
- r - 重新编码和折叠多个二进制编码的列