【问题标题】:proxy_pass not support # in nginxproxy_pass 在 nginx 中不支持 #
【发布时间】:2019-11-14 03:17:39
【问题描述】:

我是 nginx 新手,我正在尝试创建干净的 URL 模式,如果我在浏览器 "http://xx.xx.xx.xx:61001/employee" 上使用以下 URL,那么它应该路由到 "http://localhost:8080/emp/#/details"。但不幸的是,我在浏览器上收到 404 错误。即使我的应用程序已启动并正在运行。 # (特殊字符)在 nginx 中有一些问题。有人可以帮我吗?

在我的配置下:

location /employee {proxy_pass http://localhost:8080/emp/#/details;
}

浏览器出现 404 错误

这是我的完整服务器配置:

server { 
  listen 8081;
  server_name xx.xx.xxx.xxx;
  location / { root html; index index.html index.htm; }
  location /employee { proxy_pass localhost:8080/emp/#/details; }
  error_page 500 502 503 504 /50x.html;
  location = /50x.html { root html; } 
}

【问题讨论】:

  • 您可以edit您的问题,请不要在cmets中发布代码
  • @ravisharma 这样写怎么样? http://localhost:8080/emp/%23/details
  • @barbsan 我已经尝试在代码部分粘贴,但有些编辑器无法验证我的代码。所以我不得不在评论部分粘贴以给予它的热情。谢谢你的建议。
  • @MostafaHussein 我尝试使用 %23 而不是 # 但没有运气。

标签: linux nginx nginx-reverse-proxy nginx-config


【解决方案1】:

现在您正在侦听端口 8081,将其更改为 80。

server { 
  listen 80;
  server_name xx.xx.xxx.xxx;
  location / { root html; index index.html index.htm; }
  location /employee { proxy_pass localhost:8080/emp/#/details; }
  error_page 500 502 503 504 /50x.html;
  location = /50x.html { root html; } 
}

【讨论】:

    猜你喜欢
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2015-05-29
    • 2016-01-30
    • 2018-03-29
    • 2019-01-22
    相关资源
    最近更新 更多