我正在尝试为以下情况实现nginx重写规则
请求:
http://192.168.64.76/Shep.ElicenseWeb/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635
Run Code Online (Sandbox Code Playgroud)
应该重定向到:
http://localhost:82/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635
Run Code Online (Sandbox Code Playgroud)
我试了这个没有运气:
location /Shep.ElicenseWeb/ {
rewrite ^/Shep.ElicenseWeb/ /$1 last;
proxy_pass http://localhost:82;
}
Run Code Online (Sandbox Code Playgroud)
为nginx执行这样重写的正确方法是什么?
我有一个 Django 项目,已在 127.0.0.1:8888 的开发服务器上启动并运行。我正在尝试让它在我的 vps 上运行 nginx,这样我就可以在 example.com/djangoApp 上看到它。
这是我的 nginx.conf:
server {
server_name example.com;
location /otherLocation/ {
proxy_pass http://127.0.0.1:10000;
}
location /djangoApp/ {
proxy_pass http://127.0.0.1:8888;
}
Run Code Online (Sandbox Code Playgroud)
当我导航到 example.com/djangoApp 时,它会抛出一个错误:“使用 djangoApp.urls 中定义的 URLconf,Django 按以下顺序尝试了这些 URL 模式: /admin 当前路径 djangoApp/ 与以下任何内容都不匹配这些。”
我可以修改 settings.py 中的根 url 来缓解这种情况吗?