I have built a web app app.mywebapp.com
. I'm planning to implement white labeling for my users.
User example website: userwebsite.com
. I want to point their subdomain to my app.
Example: dashboard.userwebsite.com
should point to app.mywebapp.com
I have added a CNAME record in my users DNS settings
I'm using openresty
to implement the dynamic SSL
certificates handling via reverse proxy.
My webapp is running on one AWS EC2 instance with SSL being handled by loadbalancer.
I have created another EC2 instance with a loadbalancer to handle the SSL requests from my user websites.
When I type EC2 instance Public DNS in browser, I'm getting insecure SSL error with message
"sni-support-required-for-valid-ssl" certificate is not trusted
Here is the nginx.conf
file for handling SSL via openresty
user www-data;
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.mywebapp.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.mywebapp.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()
}
}
}
}