2017-06-18 75 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版本,而不是原來的。