nginx启动错误。

zhangdelei 发布于 2016/09/21 20:32
阅读 290
收藏 0

我在修改完nginx.conf配置文件后重启nginx,出现这个错误。

不知道怎么办?我是菜鸟。

nginx: [emerg] unknown "service" variable

nginx: configuration file /etc/nginx/nginx.conf test failed

加载中
-1
szwx855
szwx855
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 2m;
    server_names_hash_bucket_size 64;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
 
 
#ficdms
server {

   listen       80;
   server_name  me.cnsuning.com;
  
   fastcgi_intercept_errors on;
   #charset koi8-r;
   

  #access_log  logs/host.access.log  main;
  
   #error_page   500 502 503 504 404  /index.html;
   location  / {
          proxy_pass  http://127.0.0.1:8080$request_uri;
          proxy_set_header     Host $server_name;
          proxy_set_header     X-Real-IP       $remote_addr;
          proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;
   }
   
   location /ficdms-web-1.0.0 {
          proxy_pass  http://127.0.0.1:8080/ficdms-web-1.0.0$request_uri;
          proxy_set_header     Host $server_name;
          proxy_set_header     X-Real-IP       $remote_addr;
          proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;
   }
   
   
   
}  
  
#fabdmslocal
server {

   listen       80;
   server_name  fabdmslocal.cnsuning.com;
  
   fastcgi_intercept_errors on;
   #charset koi8-r;
   

  #access_log  logs/host.access.log  main;
  
   #error_page   500 502 503 504 404  /index.html;
   location  / {
          proxy_pass  http://127.0.0.1:8082$request_uri;
          proxy_set_header     Host $server_name;
          proxy_set_header     X-Real-IP       $remote_addr;
          proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;
   }
   
   location /ficdms-web-1.0.0 {
          proxy_pass  http://127.0.0.1:8080/ficdms-web-1.0.0$request_uri;
          proxy_set_header     Host $server_name;
          proxy_set_header     X-Real-IP       $remote_addr;
          proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;
   }
   
   
   
} 
  
  
#uaa
server {

   listen       80;
   server_name  uaa.cnsuning.com;
  
   fastcgi_intercept_errors on;
   #charset koi8-r;
   

  #access_log  logs/host.access.log  main;
  
   #error_page   500 502 503 504 404  /index.html;
   location  / {
          proxy_pass  http://127.0.0.1:6001$request_uri;
          proxy_set_header     Host $server_name;
          proxy_set_header     X-Real-IP       $remote_addr;
          proxy_set_header     X-Forwarded-For $proxy_add_x_forwarded_for;
   }
   
   
   
}  


}

按这个配置就好了。



0
Feng_Yu
Feng_Yu
这报错都说的很清楚了,不知道service这个变量。应该是你没定义这个变量吧?
0
纳兰清风
纳兰清风
配置文件起码得贴出来啊
0
红魔小贝
红魔小贝
看错误日志一步一步解决吧,没什么难的
0
zhangdelei
zhangdelei

问题已经解决,就是在nginx版本1.11.1,不能带有$符,

配置文件

location /v1/kv/cmha/service/$servicename/db/real_status/$hostname   {
  proxy_pass http://rap.taobao.org/mockjs/7429/v1/kv/cmha/service/servicename/db/real_status/hostname?;
                }
location /v1/kv/cmha/service/$servicename/db/real_status/$hostname/timestamp {
proxy_pass http://rap.taobao.org/mockjs/7429/v1/kv/cmha/service/servicename/db/real_status/hostname/timestamp?;
}

文件中带有$,无法启动,去掉$就可以了,

另一种解决方案  将nginx版本升级到1.12.7



返回顶部
顶部