nginx - nginx服务404而不传递给代理
问题描述
我有简单的设置来部署 angular、springboot、mysql 堆栈。我通过 nginx 提供这个服务,使用这个配置
server {
listen 8081;
server_name _;
root /usr/share/nginx/html;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 32;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript font/opentype image/svg+xml image/x-icon application/javascript application/x-font-ttf application/x-font-otf application/font-woff application/font-woff2 application/vnd.ms-fontobject application/octet-stream;
error_log stderr info;
access_log /dev/stdout main;
location /api {
proxy_pass http://backend:8080/;
}
location /app {
root /usr/share/nginx/html;
try_files $uri$args $uri$args/ $uri/ /index.html;
#index index.html index.htm;
}
}
应用程序服务良好,但是当我尝试获取 localhost:8081/api 它以 404 结尾,并且在日志中我看到 nginx 以 404 结尾,而没有传递到后端。难道我做错了什么?
解决方案
推荐阅读
- python - 将字符串分成对
- oracle - oracle11g 中的 PL/SQL 块
- api - Jira API 批量创建 - 创建全部或无
- php - Http POST 请求返回状态码 500
- scala - 在scala中加载和设置json的值
- twitter-bootstrap - 覆盖 Bootstrap 的单选按钮
- javascript - 为什么这个窗口在关闭后没有打开(chrome 扩展)?
- javascript - 如何在存储过程中将容器名称作为 Azure cosmos DB 查询的参数传递?
- python-3.x - 如何使用 Python 中的 Plotly Express 在同一 y 轴上绘制多条线并放置 y 标签、垂直线
- html - Mathjax3 溢出引导列