【问题标题】:Configure NGINX to work with angular issue on reloading page配置 NGINX 以处理重新加载页面上的角度问题
【发布时间】:2017-07-04 14:55:15
【问题描述】:

我已经阅读了部署文档以使用 NGINX 服务器部署 Angular 4 项目。但是当我使用 Angular 应用程序的路由重新加载时,会显示此错误:

http://www.mydomain.com.ec/swissecomer/myRoute

代码:“MethodNotAllowedError”
消息:“不允许 GET”

这是我的 nginx 服务器中的 conf 文件:

    upstream proyectoWeb {
        ip_hash;
        server localhost:8087;

    }

    server {

        listen 8088;
        proxy_pass proyectoWeb;
        server_name 200.31.25.34 192.168.5.27  www.mydomain.com localhost;
        root /u01/servidores/;


        location swissecomer/ {
            index index.html index.htm;
            try_files $uri $uri/ /index.html;
        }

        access_log /var/log/nginx/access_log combined;

    }

当我点击这些网址时,它显示的网页很好:

但是如果我点击下一个 url http://www.mydomain.com.ec/swissecomer ngix 服务器会继续加载,直到它在浏览器中显示超时错误。

感谢您的回复。

【问题讨论】:

    标签: angular nginx server


    【解决方案1】:

    你能不能试试location /swissecomer,而不是正斜杠也需要匹配要使用的位置块。

    【讨论】:

      【解决方案2】:

      我找到了答案,块位置需要像这样稍微改变一下:

      location swissecomer/ {
        index index.html index.htm;
        try_files $uri $uri/ /swissecomer/index.html;
      }
      

      【讨论】:

        猜你喜欢
        • 2017-10-22
        • 1970-01-01
        • 2014-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-20
        • 2017-11-22
        相关资源
        最近更新 更多