我有一個在本地機器上開發的ember.js應用程序。我使用restify/node.js服務器使其在本地可用。ember.js應用程序不會使用NGINX服務器更新URI的hashtag部分
當我在我的應用程序瀏覽,地址欄的變化是這樣的:
例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)
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 /點頭e服務器(如我的開發機器)和一切工作正常當我連接到此服務器(!)。 nginx和restify服務器都指向相同的文件。
EDIT 2
我發現,當我使用網絡重定向我的問題發生。 如果我使用像http://test.server/application/index.html
這樣的地址,一切正常 如果我使用http://web.redirection/application/index.html
它不起作用。
所以這是我的nginx conf,它沒有正確地將web.redirection URI重定向到test.server或類似的東西。
有人有想法嗎?我錯過了什麼?我應該改變什麼來完成這項工作?
EDIT 3和溶液
我使用的Web重定向是A型DNS記錄。這不起作用。使用CNAME類型的DNS記錄解決了這個問題。
你能確認你的應用程序應用程序所需的所有文件都正確部署到'/ usr/share/nginx/test'嗎? – intuitivepixel
是的,我可以證實這一點:我做了幾個git克隆和那些不工作的是在遠程服務器上 – lauhub