1. 程式人生 > >nginx: [emerg] "upstream" directive is not allowed

nginx: [emerg] "upstream" directive is not allowed

"upstream"

配置完nginx,在啟動的時候遇到如下問題:
nginx: [emerg] "upstream" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:7

配置nginx.conf,如下:
upstream con {
server 127.0.0.1:8080;
}


解決辦法:

upstream backend 位置放錯了, upstream位置應該放在http模塊裏面 但必須是在server模塊的外面


http
{
include mime.types;
default_type application/octet-stream;

server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
..................................................

upstream con {
server 127.0.0.1:8080;
}

}
對此段代碼放入httpd模塊中,重啟服務可完成問題的解決。

nginx: [emerg] "upstream" directive is not allowed