nginx - NGINX 在相同的 url 上提供内容而无需重定向
问题描述
我有一个应用程序用于从我的网站上获取此 URL 上的数据 -
example.com/android/android_script.php?table=something&content=otherthing
我的网站是在 apache2 上使用 vanilla PHP 和 jquery 构建的。我在 NGINX 上使用 nuxt 和 laravel 重新制作了我的网站。我为后端连接设置了 /api 路由。我无法在我的 Android 应用中更改我的 URL,因此我试图在同一个 URL 上提供内容。我正在像这样在 Nginx 中重定向该 URL -
rewrite ^/android/android_script3.php$ /api/android permanent;
//it changes
//example.com/android/android_script.php?table=something&content=otherthing
//to
//example.com/api/android?table=something&content=otherthing
它可以在浏览器中运行,但是当我打开应用程序时,数据加载在应用程序中不起作用。现在我想在同一个 URL 上提供相同的内容而不进行重定向。
解决方案
我使用了代理通行证。
location = /android/android_script.php {
proxy_pass https://example.com/api/android;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
推荐阅读
- r - 重新排列数据,使单个单元格成为标题
- android - Visual Studio 2017 与 Visual Studio 2019 与 Android 应用程序开发的区别
- replace - 全部转换到
使用 BBEdit Grep
- delphi - DeactivateActCtx 在 Delphi Excel COM 加载项中引发错误
- javascript - 为什么这个函数只返回真,因为没有其他语句使它在非真条件下返回假?
- django - 如何获得 Django 服务器错误 500 报告
- java - IntelliJ 抛出 Java.Net.SocketException:无法打开调试器,“套接字已关闭”
- yii2 - Yii2 ActiveForm Stripe 令牌
- python - 使用 CSV 文件中的 tf.data.Dataset.take() 加载数据时内核崩溃
- python - 一起迭代字典和数据框的更快方法?