2
我嘗試返回503狀態碼,當用戶代理頭具有特定值我想外面的位置塊內但當我重新加載此配置nginx的failes重裝: ?
upstream api{
server 127.0.0.1:1336;
}
# the nginx server instance
server {
listen 0.0.0.0:80;
server_name api.project.com;
# if($http_user_agent = "android") {
# return 503;
# }
# pass the request to the node.js server with the correct headers
location/{
# if($http_user_agent = "android") {
# return 503;
# }
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://api/;
proxy_redirect off;
}
}
任何想法,什麼是錯,我使用nginx的/ 1.4.7
從系統日誌:!
nginx: [emerg] unknown directive "if($http_user_agent"
什麼是nginx錯誤信息? – 2014-10-01 14:36:20
@John我剛剛得到重裝載nginx配置(通過systemctl):nginx.serviceJob失敗。我可以在其他地方找到更具體的錯誤消息嗎? – 2014-10-01 14:37:51
那麼日誌通常在/ var/log/nginx /中。請檢查端口是否已被使用,使用 'netstat -tupln' – 2014-10-01 14:40:08