我有一个我在本地机器上开发的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配置,因为该应用程序可以在本地服务器上完美运行。
此服务器的NGINX配置为:
test.server.conf(符号链接到/etc/nginx/sites-enabled/test.server.conf)
server {
server_name test.server web.redirection;
root /usr/share/nginx/test;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location ~ \.csv$ {
alias /usr/share/nginx/test/$uri;
}
}
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
我发现当我使用网络重定向时,我的问题就出现了。
如果我使用像http://test.server/application/index.html
这样的地址,一切正常
如果我使用http://web.redirection/application/index.html
则无效。
所以这是我的nginx conf,它没有正确地将web.redirection URI重定向到test.server或类似的东西。
有人有想法吗?我错过了什么?我应该改变什么来使这项工作?
编辑3和解决方案
我使用的网络重定向是A型DNS记录。这不起作用。使用CNAME类型的DNS记录可以解决问题。
答案 0 :(得分:1)
不,这与nginx无关,任何超过#
的东西都不会发送到服务器,javascript代码应该处理这个,我建议使用firebug或任何检查器来确保所有正在加载您的js文件,并且没有任何失败并出现404错误,还会检查检查器控制台上的控制台错误。
答案 1 :(得分:0)
问题来自于从web.redirection到test.server的DNS重定向。
这是A型记录:这不起作用。
使用直接指向test.server的CNAME类型记录。