2017-06-18 269 views
1

我刚刚安装了openresty 1.9.15.1并且想试试ssl_certificate_by_lua_block指令。nginx未知指令“ssl_certificate_by_lua_block”错误

但我得到一个错误说

[EMERG] 13854#0:/etc/nginx/nginx.conf未知的指令 “ssl_certificate_by_lua_block”

错误信息被写入错误日志当我重新加载nginx使用/etc/init.d/nginx reload

但有一点奇怪的是,控制台说与ok与重新加载操作。

Reloading nginx configuration nginx         [ OK ] 

nginx -t说我的nginx.conf语法没问题。我的nginx.conf的

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 
nginx: configuration file /etc/nginx/nginx.conf test is successful 

部分看起来是这样的:

server { 
    listen 443 ssl; 
    server_name mydomain.com; 

    # SSL 
    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; 
    ssl_certificate_by_lua_block { 
     print("About to initiate a new SSL handshake!") 
    } 
    location/{ 
     proxy_pass http://$host$request_uri; 
     proxy_set_header X-Forwarded-Host $host; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Proto $scheme; 
     proxy_http_version 1.1; 
    } 

    access_log /var/log/nginx/mydomain.com-443.log cloudwatch_log; 
    error_log /var/log/nginx/mydomain.com-443.error ; 
} 

这是我的nginx的版本:

nginx -V 
nginx version: openresty/1.9.15.1 
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 
built with OpenSSL 1.0.2l 25 May 2017 
TLS SNI support enabled 
configure arguments: --prefix=/usr/local/openresty/nginx --with-debug --with-cc-opt='-DNGX_LUA_USE_ASSERT 
-DNGX_LUA_ABORT_AT_PANIC -O2' --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.59 
--add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 
--add-module=../set-misc-nginx-module-0.30 --add-module=../form-input-nginx-module-0.12 
--add-module=../encrypted-session-nginx-module-0.05 --add-module=../ngx_postgres-1.0rc7 
--add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.5 --add-module=../ngx_lua_upstream-0.05 
--add-module=../headers-more-nginx-module-0.30 --add-module=../array-var-nginx-module-0.05 
--add-module=../memc-nginx-module-0.17 --add-module=../redis2-nginx-module-0.13 
--add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 
--add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib 
--sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log 
--http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi 
--http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy 
--http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi 
--lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-sha1=/usr/include/openssl 
--with-md5=/usr/include/openssl --with-http_stub_status_module --with-http_secure_link_module --with-pcre-jit 
--with-http_auth_request_module --with-http_addition_module --with-http_gunzip_module 
--with-http_image_filter_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module 
--with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module 
--with-http_sub_module --with-http_xslt_module --with-stream --with-ipv6 --with-openssl=/root/openssl-1.0.2l 

有什么毛病我安装openresty的?

installation document

强烈建议使用OpenResty发布其整合的Nginx,ngx_lua,LuaJIT 2.1,以及其他强大的同伴Nginx的模块和Lua库。

这就是为什么我认为ssl_certificate_by_lua_block可用,一旦openresty安装。

回答

0

很可能你已经安装了两个nginx版本,并且为原始nginx配置了服务。 您尝试编辑原始nginx使用的nginx.conf文件。添加ssl_certificate_by_lua_block(和 -

OpenResty版本与--prefix=/usr/local/openresty/nginx

这意味着OpenResty版本默认情况下会寻找/usr/local/openresty/nginx/conf/nginx.conf

对于快速检查建其他人需要)指令到这个文件并启动OpenResty nginx:

sudo /usr/local/openresty/bin/openresty -g 'daemon off;' 

它应该工作。

您将需要配置您的nginx服务使用OpenResty版本,而不是原来的。