ember.js应用程序不使用NGINX服务器更新URI的哈希标记部分

ember.js应用程序不使用NGINX服务器更新URI的哈希标记部分,nginx,ember.js,Nginx,Ember.js,我在本地机器上开发了一个ember.js应用程序。我使用restify/node.js服务器使其在本地可用 当我在应用程序中导航时,地址栏会发生如下变化: 示例1 1. http://dev.server:3000/application/index.html#about 2. http://dev.server:3000/application/index.html#/items 3. http://dev.server:3000/application/index.html#/items/1

我在本地机器上开发了一个ember.js应用程序。我使用restify/node.js服务器使其在本地可用

当我在应用程序中导航时,地址栏会发生如下变化:

示例1

1. http://dev.server:3000/application/index.html#about
2. http://dev.server:3000/application/index.html#/items
3. http://dev.server:3000/application/index.html#/items/1
4. http://dev.server:3000/application/index.html#/items/2
我现在尝试在运行nginx的远程测试服务器上部署它

虽然本地的一切都很好,但是我可以导航到我的web应用程序,但是在标签后面的URI部分没有更新

在任何浏览器中:
http://test.server/application/index.html
始终显示在我的地址栏中。对于与例1相同的点击顺序,我始终有:

1. http://web.redirection/application/index.html
2. http://web.redirection/application/index.html
3. http://web.redirection/application/index.html
4. http://web.redirection/application/index.html
此外,如果我直接输入完整的URI
http://web.redirection/application/index.html#/items/1
浏览器将仅显示位于
http://test.server/application/index.html
(这绝对不是预期的行为)

我认为这来自于我的NGINX配置,因为该应用程序可以在本地restify服务器上完美工作

此服务器的NGINX配置为:

test.server.conf(符号链接到/etc/nginx/sites enabled/test.server.conf)

nginx.conf

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log debug;

    gzip on;
    gzip_disable "msie6";


    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
编辑: 为了确保我的测试服务器上没有丢失的文件:我运行了一个restify/node服务器(就像在我的开发机器上一样),当我连接到这个服务器时,一切都正常(!)。nginx和restify服务器都指向相同的文件

编辑2

我发现我的问题发生在使用web重定向时。 如果我使用像
http://test.server/application/index.html
一切正常 如果我使用
http://web.redirection/application/index.html
它不工作

这是我的nginx配置,它没有正确地将web.redirection URI重定向到test.server或类似的东西

有人有主意吗?我错过了什么?我应该做什么改变才能让这一切顺利进行

编辑3和解决方案


我使用的web重定向是A类型DNS记录。这是行不通的。使用CNAME类型的DNS记录可以解决此问题

不,这与nginx无关,任何超过
#
的东西都不会发送到服务器,javascript代码应该可以处理这个问题,我建议使用firebug或任何检查器来确保所有js文件都已加载,并且没有任何东西会因404错误而失败,还要在inspector控制台上检查控制台错误。

问题来自从web.redirection到test.server的DNS重定向

这是A型记录:这不起作用


使用直接指向test.server的CNAME类型记录可以工作。

您能否确认您的ember应用程序所需的所有文件都已正确部署到
/usr/share/nginx/test
?是,我可以确认这一点:我制作了几个git克隆,不起作用的都在远程服务器上+1添加日志转换:对你的应用程序为true,并查看路由器是否正在按照你在导航应用程序时预期的方式进行转换。很可能本地可用的某些资源不在生产中。是的,它正在按预期进行转换。一切都在生产中。为了检查这一点,我在测试服务器上运行了一个restify服务器,该服务器指向与nginx服务器路径完全相同的代码:一切正常!所以我真的相信(即使我同意不应该将#之后的部分发送到服务器)这来自nginx。可能是我的规则过滤了一些不应该过滤的东西?好吧,我很抱歉,因为我错过了一些我认为可能会导致问题的东西:我实际上有一个web重定向,正如在我的编辑中所解释的,当我使用它时,问题就出现了(当我使用服务器名称时,问题就消失了),经过一个愉快的夜晚,我找到了解决办法:问题在于网络重定向。使用A记录类型可防止更新#之后的零件。使用CNAME记录类型进行web重定向可以解决此问题。我对这种差异没有经验,很抱歉我没有意识到这种差异是如此重要。
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log debug;

    gzip on;
    gzip_disable "msie6";


    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}