我正在使用AWS EC2 ubuntu 18.04
实例来设置反向代理服务器,以实现Web应用程序白标的概念。
我安装了nginx
openresty
和lua
这里是各个版本:
nginx version: nginx/1.14.0 (Ubuntu)
nginx version: openresty/1.15.8.2
Lua: 5.1.5
我在nginx
中创建正确的配置文件时遇到问题>
这是我的nginx.conf
文件代码:
user ubuntu www; events { worker_connections 1024; } http { lua_shared_dict auto_ssl 1m; lua_shared_dict auto_ssl_settings 64k; resolver 8.8.8.8 ipv6=off; init_by_lua_block { auto_ssl = (require "resty.auto-ssl").new() auto_ssl:set("allow_domain", function(domain) return true end) auto_ssl:init() } init_worker_by_lua_block { auto_ssl:init_worker() } server { listen 443 ssl; ssl_certificate_by_lua_block { auto_ssl:ssl_certificate() } ssl_certificate /etc/ssl/resty-auto-ssl-fallback.crt; ssl_certificate_key /etc/ssl/resty-auto-ssl-fallback.key; proxy_ssl_server_name on; location / { proxy_set_header Host app.mydomain.com; proxy_set_header Referer $host$uri; proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; proxy_set_header User-Agent $http_user_agent; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Accept-Encoding ""; proxy_set_header Accept-Language $http_accept_language; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_read_timeout 5m; proxy_pass https://app.mydomain.com; } } server { listen 80; location /.well-known/acme-challenge/ { content_by_lua_block { auto_ssl:challenge_server() } } location / { return 301 https://$host$request_uri; } } server { listen 127.0.0.1:8999; client_body_buffer_size 128k; client_max_body_size 128k; location / { content_by_lua_block { auto_ssl:hook_server() } } } }
[重新启动
nginx
服务时,出现以下错误:
unknown directive "init_by_lua_block" in /etc/nginx/nginx.conf
我正在使用AWS EC2 ubuntu 18.04实例来设置反向代理服务器,以实现Web应用程序白标的概念。我安装了nginx openresty和lua分别是...
最后,我了解到必须使用openresty
而不是nginx
启动服务器。