Lua-resty-auto-ssl: لم يبدأ Nginx بعد استبدال محتويات nginx.conf

تم إنشاؤها على ٢ فبراير ٢٠١٩  ·  11تعليقات  ·  مصدر: auto-ssl/lua-resty-auto-ssl

حاولت تثبيت lua-resty-auto-ssl على تثبيت جديد من دبيان 9

فعلت ما يلي

apt update
apt install nginx
apt install build-essential
apt install luarocks
luarocks install lua-resty-auto-ssl
mkdir /etc/resty-auto-ssl
chown www-data /etc/resty-auto-ssl

ثم استبدلت /etc/nginx/nginx.conf بأدنى مثال منشور هنا في اقرأ لي https://github.com/GUI/lua-resty-auto-ssl

ولكن بعد استبدال محتويات ngix.conf بأدنى مثال ، لم يعد nginx قادرًا على البدء

انا حصلت

root<strong i="13">@vultr</strong>:/etc/nginx# /etc/init.d/nginx start
[....] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
 failed!
root<strong i="14">@vultr</strong>:/etc
root<strong i="17">@vultr</strong>:/etc/nginx# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2019-02-02 20:17:41 UTC; 50s ago
     Docs: man:nginx(8)
  Process: 6606 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 483 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 6923 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 496 (code=exited, status=0/SUCCESS)

Feb 02 20:17:41 vultr.guest systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 02 20:17:41 vultr.guest nginx[6923]: nginx: [emerg] unknown directive "lua_shared_dict" in /etc/nginx/nginx.conf:14
Feb 02 20:17:41 vultr.guest nginx[6923]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 02 20:17:41 vultr.guest systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 02 20:17:41 vultr.guest systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 02 20:17:41 vultr.guest systemd[1]: nginx.service: Unit entered failed state.
Feb 02 20:17:41 vultr.guest systemd[1]: nginx.service: Failed with result 'exit-code'.

محتويات nginx.conf الخاص بي

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
  worker_connections 1024;
}

http {
  # The "auto_ssl" shared dict should be defined with enough storage space to
  # hold your certificate data. 1MB of storage holds certificates for
  # approximately 100 separate domains.
  lua_shared_dict auto_ssl 1m;
  # The "auto_ssl_settings" shared dict is used to temporarily store various settings
  # like the secret used by the hook server on port 8999. Do not change or
  # omit it.
  lua_shared_dict auto_ssl_settings 64k;

  # A DNS resolver must be defined for OCSP stapling to function.
  #
  # This example uses Google's DNS server. You may want to use your system's
  # default DNS servers, which can be found in /etc/resolv.conf. If your network
  # is not IPv6 compatible, you may wish to disable IPv6 results by using the
  # "ipv6=off" flag (like "resolver 8.8.8.8 ipv6=off").
  resolver 8.8.8.8;

  # Initial setup tasks.
  init_by_lua_block {
    auto_ssl = (require "resty.auto-ssl").new()

    -- Define a function to determine which SNI domains to automatically handle
    -- and register new certificates for. Defaults to not allowing any domains,
    -- so this must be configured.
    auto_ssl:set("allow_domain", function(domain)
      return true
    end)

    auto_ssl:init()
  }

  init_worker_by_lua_block {
    auto_ssl:init_worker()
  }

  # HTTPS server
  server {
    listen 443 ssl;

    # Dynamic handler for issuing or returning certs for SNI domains.
    ssl_certificate_by_lua_block {
      auto_ssl:ssl_certificate()
    }

    # You must still define a static ssl_certificate file for nginx to start.
    #
    # You may generate a self-signed fallback with:
    #
    # openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \
    #   -subj '/CN=sni-support-required-for-valid-ssl' \
    #   -keyout /etc/ssl/resty-auto-ssl-fallback.key \
    #   -out /etc/ssl/resty-auto-ssl-fallback.crt
    ssl_certificate /etc/ssl/resty-auto-ssl-fallback.crt;
    ssl_certificate_key /etc/ssl/resty-auto-ssl-fallback.key;
  }

  # HTTP server
  server {
    listen 80;

    # Endpoint used for performing domain verification with Let's Encrypt.
    location /.well-known/acme-challenge/ {
      content_by_lua_block {
        auto_ssl:challenge_server()
      }
    }
  }

  # Internal server running on port 8999 for handling certificate tasks.
  server {
    listen 127.0.0.1:8999;

    # Increase the body buffer size, to ensure the internal POSTs can always
    # parse the full POST contents into memory.
    client_body_buffer_size 128k;
    client_max_body_size 128k;

    location / {
      content_by_lua_block {
        auto_ssl:hook_server()
      }
    }
  }
}

هل لديك فكرة ما الخطب؟

ال 11 كومينتر

يبدو أن nginx لا يتم تحميل lua بشكل صحيح.
هيريس ملف عامل السفن الخاص بي ، استنادًا إلى نظام أوبونتو 16:04. ربما سيساعدك:
https://pastebin.com/dnENPEaM
مع الإعداد الصحيح ، يجب أن يعمل التكوين الخاص بك على ما يرام

يبدو أن nginx لا يتم تحميل lua بشكل صحيح.
هيريس ملف عامل السفن الخاص بي ، استنادًا إلى نظام أوبونتو 16:04. ربما سيساعدك:
https://pastebin.com/dnENPEaM
مع الإعداد الصحيح ، يجب أن يعمل التكوين الخاص بك على ما يرام

شكرًا ، سأقوم يدويًا بتشغيل الأوامر الموجودة في الملف لتثبيته. لا بأس في تثبيت nginx باستخدام apt قبل كل شيء ، أليس كذلك؟

لقد بدأت في متابعة ملفك ، لكن لا أفهم ما تفعله هذه السطور

ADD mime.types /etc/nginx/
ADD fastcgi_params /etc/nginx/

ADD ./start.sh /root/

لقد فعلت كل شيء حتى تلك النقطة دون أخطاء

ربما يكون من الأفضل لك استخدام الصراحة

لسوء الحظ لم ينجح حتى الآن. قمت بما يلي في تثبيت جديد لـ Debian 9 ، هذه المرة لم أقم بتثبيت Ngix لكنني قمت بتثبيت Openresty بدلاً من ذلك

apt update
apt upgrade
wget -qO - https://openresty.org/package/pubkey.gpg | apt-key add -
apt-get -y install software-properties-common
add-apt-repository -y "deb http://openresty.org/package/debian $(lsb_release -sc) openresty"
apt-get update
apt-get install openresty
apt install luarocks
apt install build-essential
luarocks install lua-resty-auto-ssl
mkdir /etc/resty-auto-ssl
chown www-data /etc/resty-auto-ssl

ثم قمت بعد ذلك بتغيير محتويات /etc/openresty/nginx.conf

لكني أحصل على ما يلي بعد محاولة بدئه

root<strong i="10">@vultr</strong>:/etc/openresty# /etc/init.d/openresty start
[....] Starting openresty (via systemctl): openresty.serviceJob for openresty.service failed because the control process exited with error code.
See "systemctl status openresty.service" and "journalctl -xe" for details.
 failed!

والخطأ هو

root<strong i="14">@vultr</strong>:~# systemctl status --no-pager --full openresty.service      
● openresty.service - full-fledged web platform
   Loaded: loaded (/lib/systemd/system/openresty.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-02-03 19:44:22 UTC; 16min ago
  Process: 18855 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /usr/local/openresty/nginx/logs/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 18886 ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 12782 (code=exited, status=0/SUCCESS)

Feb 03 19:44:22 vultr.guest systemd[1]: Starting full-fledged web platform...
Feb 03 19:44:22 vultr.guest nginx[18886]: nginx: [emerg] BIO_new_file("/etc/ssl/resty-auto-ssl-fallback.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/ssl/resty-auto-ssl-fallback.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
Feb 03 19:44:22 vultr.guest nginx[18886]: nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed
Feb 03 19:44:22 vultr.guest systemd[1]: openresty.service: Control process exited, code=exited status=1
Feb 03 19:44:22 vultr.guest systemd[1]: Failed to start full-fledged web platform.
Feb 03 19:44:22 vultr.guest systemd[1]: openresty.service: Unit entered failed state.
Feb 03 19:44:22 vultr.guest systemd[1]: openresty.service: Failed with result 'exit-code'.

لقد حصلت عليه للبدء بالجري

openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj '/CN=sni-support-required-for-valid-ssl' \
> -keyout /etc/ssl/resty-auto-ssl-fallback.key -out /etc/ssl/resty-auto-ssl-fallback.crt

المشكلة الوحيدة التي أواجهها الآن هي أنه إذا ذهبت إلى https://mydomain.com ، فإن الشهادة تكون من خلال "sni-support-required-for-valid-ssl" يبدو أنها لا تنشئ شهادة Letsencrypt لنطاقي.

إنها قضية إذن. إذا قمت بتغيير مستخدم nginx إلى الجذر ، فسيعمل كل شيء بشكل جيد. سأجد طريقة لإصلاحه وبعد ذلك سأكتب دليل التثبيت.

شكرا لمساعدتك. لقد كتبت دليلًا خطوة بخطوة للرجوع إليه في المستقبل

Intalling lua resty auto ssl على دبيان

محتوى nginx.conf الخاص بي

`بيانات المستخدم على شبكة الاتصالات العالمية ؛
worker_processes السيارات ؛
pid /run/nginx.pid ؛

بعيدًا عن حرف الهروب إذا كنت ستستخدم هذا التكوين

تشمل /etc/nginx/modules-enabled/*.conf ؛

الأحداث {
اتصالات العمال 768 ؛
}

http {

# التكوين الأساسي
sendfile على ؛
على tcp_nopush ؛
tcp_nodelay على ؛
keepalive_timeout 65 ؛
types_hash_max_size 2048 ؛
تشمل /etc/nginx/mime.types ؛
تطبيق default_type / ثماني دفق ؛

# تكوين ssl
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 ؛
ssl_prefer_server_ciphers على ؛

# تسجيل التكوين
log_format مخصص "$ remote_addr - $ remote_user [$ time_local]"
"" طلب $ "حالة $ body_bytes_sent"
'"http_referer $" "$ http_user_agent" "$ http_x_forwarded_for"'؛

access_log /var/log/nginx/access.log مخصص ؛
error_log /var/log/nginx/error.log ؛

# gzip
تشغيل gzip

# تهيئة المضيف الظاهري
تشمل /etc/nginx/conf.d/*.conf ؛

تضمين / etc / nginx / sites-enabled / * ؛

lua_shared_dict prometheus_metrics 10M ؛
lua_package_path "/home/kunal/Documents/nginx-lua-prometheus/؟.lua ؛؛"؛
init_worker_by_lua_block {
prometheus = يتطلب ("prometheus"). init ("prometheus_metrics")
metric_requests = p rometheus: counter (
"nginx_http_requests_total"، "عدد طلبات HTTP"، {"host"، "status"})
metric_latency = p rometheus: المدرج التكراري (
"nginx_http_request_duration_seconds" ، "وقت استجابة طلب HTTP" ، {"host"})
metric_connections = p rometheus: gauge (
"nginx_http_connections"، "عدد اتصالات HTTP"، {"state"})
}
log_by_lua_block {
طلبات metric
metric_ latency: مراقبة (tonumber (ngx.var.request_time) ، {ngx.var.server_name})
}
"

أي اقتراح على ما هو الخطأ هنا؟

شكرا لمساعدتك. لقد كتبت دليلًا خطوة بخطوة للرجوع إليه في المستقبل

Intalling lua resty auto ssl على دبيان

مرحبًا @ arya6000 ،

أواجه نفس المشكلات ، لكن الرابط الذي نشرته معطل الآن :(

احسب هل يمكن أن تساعدني؟

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات