nginx - Nginx:位置=/不使用位置/
问题描述
我有一个包含两个位置的 nginx 主机文件,我想让确切的 / 转到 index.html 和 /something 转到我的代理。
我有一个要用于 my_domain.com 的 HTML 登录页面,并且我的 React 应用程序在代理通行证中提供,所以我希望 my_domain.com/something 指向我的代理(反应应用程序)。
上面使用的东西可以是任何字符串
我已经尝试过了,但它不起作用它总是重定向到我的第二个位置:
server_name domain.com www.domain.com;
index index.php index.html index.htm;
location = / {
root /var/www/domain;
index index.html;
try_files $uri /index.html;
}
location / {
proxy_pass http://localhost:3020;
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;
proxy_redirect off;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
我希望你能帮助我。
谢谢。
解决方案
推荐阅读
- node.js - Node Express - 在 multer 保存文件之前处理表单数据
- mysql - Spring Boot JDBC 和 MySQL 中的原子性
- oop - 方法 JavaFx TreeItem getRoot() 不可见。不是 OOP/MVC 的原因是什么?
- python - 如何使用 pandas 数据框构建人口金字塔
- pytorch - 在 PyTorch 中使用 PackedSequence 时如何处理 LSTM 层之间的丢失?
- php - 如何强制 Laravel 验证类不刷新请求数据?
- python-3.x - 组相邻坐标
- r - 为什么 which() 没有找到我序列中存在的特定数字?
- pyspark - pyspark 在日期框架中创建具有条件的 structType
- amazon-web-services - 满载运行时如何实现基于日期的文件夹分区?