2010-02-16 85 views
1

我有一個域example.com和「替代」some-example.com。我試圖從some-example.com直接流量example.com在使用nginx的一個簡單的服務器的聲明如下:Nginx服務器匹配太多的URL

server { 
    listen 80; 
    server_name some-example.com; 
    rewrite ^/(.*) http://example.com/$1 permanent; 
} 

我不是100%肯定,如果這是正確的規則,但我有另一個虛擬主機上服務器,這不是問題所在,但有必要了解我遇到的問題。

server { 
    listen  8745; 
    server_name localhost; 
    <other stuff goes here> 
} 

打到<my server IP>:8745將去那個虛擬主機,按預期工作。不過我有另一虛擬主機是這樣的:

server { 
    listen  8746; 
    server_name localhost; 
    <other stuff goes here> 
} 

但是我所有的要求,以<my server IP>:8746example.com。我很困惑,我沒有真正理解nginx,所以任何幫助,將不勝感激,爲什麼發生這種情況。我在開始時就提到過這個規則,因爲我認爲它與此有關。如果需要更多信息,我可以提供。

(同樣,這會爲服務器故障是更好嗎?)

+0

如果刪除該重寫規則,它是否可以解決問題?此外,我想你將不得不提供更多的信息(完整的配置文件(S)) – 2010-02-19 13:01:27

+0

這是在ServerFault上回答(嗯,我想通了)。看到這裏:http://serverfault.com/questions/113199/nginx-server-matching-too-many-urls它必須與Wordpress反彈URL到我的IP端口80.我應該提到它運行Wordpress。 – Zack 2010-02-21 17:12:18

回答

0

我問這對服務器故障也,但是我發現我自己的原因。以下摘錄摘自this question

事實證明,這不是一個nginx 問題。我大概應該注意到, <my server IP>:8746運行Wordpress 安裝; WordPress的有一個選項 集(在wp_options表,行 有我的2 option_id和 的siteurloption_name)到<some domain>.com,我改變了對<some domain>.com:8746它工作得很好。