2015-04-02 16 views
0

我想用nginx爲我的資產文件提供服務。 ngnix服務器監聽端口如8000(它必須不同於80),我想通過子域名像assets.mydomain.com訪問這些文件。具有不同端口和子域的資產文件的Nginx配置

我嘗試配置,但我不能這樣做。我應該如何配置?謝謝你的回答。

server { 
    listen 8000; 
    server_name localhost; 

    location/{ 
     # First attempt to serve request as file, then 
     # as directory, then fall back to displaying a 404. 
     try_files $uri $uri/ =404; 
     # Uncomment to enable naxsi on this location 
     # include /etc/nginx/naxsi.rules 
     } 

} 
# another virtual host using mix of IP-, name-, and port-based configuration 
server { 
    listen 8000; 
    server_name assets.localhost; 

    location /assets/ { 
       root /var/www/html/skytrip/assets 
     try_files $uri $uri/ =404; 
    } 
} 

回答

1

一般而言,您應該對您遇到的問題更具體。您對該配置有何期望?究竟發生了什麼?有錯誤嗎?你能發送日誌文件的最後一行嗎? etc。

你忘記了根指令後的分號?