I am attempting to use SSL via the reverse proxy with custom certificates (not Let'sEncrypt). I am trying to set this up using only IP addresses and no domains. When I use the host IP address as the ssl.domains and access the site via https://1.2.3.4, nginx incorrectly serves the meteor up default.crt and default.key rather than my custom certificates (the served certificate has subject letsencrypt-nginx-proxy-companion).
If I swap to using a domain instead of an IP address for ssl.domains (while keeping the rest of the config the same) and access the site via https://mydomain.com, nginx correctly serves my custom certificates instead. The output of mup proxy nginx-config is the same between these setups apart from the upstream and server_name fields.
I'm not sure if it's an issue with the generated nginx config, or if I should be putting another value in for the ssl.domains field in order to use an ip address rather than a domain.
Mup version (mup --version): 1.4.6
Mup config
module.exports = {
servers: {
one: {
// TODO: set host address, username, and authentication method
host: '1.2.3.4',
username: 'root',
password: 'password',
// or neither for authenticate from ssh-agent
}
},
app: {
// TODO: change app name and path
name: 'secure-chat',
path: '../',
servers: {
one: {},
},
buildOptions: {
serverOnly: true,
},
env: {
// TODO: Change to your app's url
// If you are using ssl, it needs to start with https://
ROOT_URL: 'https://1.2.3.4',
MONGO_URL: 'mongodb://mongodb/meteor',
MONGO_OPLOG_URL: 'mongodb://mongodb/local',
// PORT: 3000,
},
docker: {
// change to 'abernix/meteord:base' if your app is using Meteor 1.4 - 1.5
image: 'abernix/meteord:node-12-base',
// prepareBundle: true,
},
// Show progress bar while uploading bundle to server
// You might need to disable it on CI servers
enableUploadProgressBar: true
},
mongo: {
version: '3.4.1',
servers: {
one: {}
}
},
// (Optional)
// Use the proxy to setup ssl or to route requests to the correct
// app when there are several apps
proxy: {
domains: '1.2.3.4',
ssl: {
crt: './bundle.pem',
key: './private.key',
forceSSL: true,
}
}
};
===== 1.2.3.4 ======
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
default $http_x_forwarded_port;
'' $server_port;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
default upgrade;
'' close;
}
# Apply fix for very long server names
server_names_hash_bucket_size 128;
# Default dhparam
ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
default off;
https on;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers off;
resolver 67.207.67.2 67.207.67.3;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
server {
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
access_log /var/log/nginx/access.log vhost;
return 503;
}
server {
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 443 ssl http2;
access_log /var/log/nginx/access.log vhost;
return 503;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_certificate /etc/nginx/certs/default.crt;
ssl_certificate_key /etc/nginx/certs/default.key;
}
# 1.2.3.4
upstream 1.2.3.4 {
## Can be connected with "bridge" network
# secure-chat
server 172.17.0.5:80;
}
server {
server_name 1.2.3.4;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
# Do not HTTPS redirect Let'sEncrypt ACME challenge
location /.well-known/acme-challenge/ {
auth_basic off;
allow all;
root /usr/share/nginx/html;
try_files $uri =404;
break;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
server_name 1.2.3.4;
listen 443 ssl http2 ;
access_log /var/log/nginx/access.log vhost;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_certificate /etc/nginx/certs/1.2.3.4.crt;
ssl_certificate_key /etc/nginx/certs/1.2.3.4.key;
add_header Strict-Transport-Security "max-age=31536000" always;
include /etc/nginx/vhost.d/1.2.3.4;
location / {
proxy_pass http://1.2.3.4;
}
}
I am attempting to use SSL via the reverse proxy with custom certificates (not Let'sEncrypt). I am trying to set this up using only IP addresses and no domains. When I use the host IP address as the ssl.domains and access the site via https://1.2.3.4, nginx incorrectly serves the meteor up default.crt and default.key rather than my custom certificates (the served certificate has subject letsencrypt-nginx-proxy-companion).
If I swap to using a domain instead of an IP address for ssl.domains (while keeping the rest of the config the same) and access the site via https://mydomain.com, nginx correctly serves my custom certificates instead. The output of mup proxy nginx-config is the same between these setups apart from the upstream and server_name fields.
I'm not sure if it's an issue with the generated nginx config, or if I should be putting another value in for the ssl.domains field in order to use an ip address rather than a domain.
Mup version (
mup --version
): 1.4.6Mup config
Output of command: mup proxy nginx-config (after mup setup && mup deploy)