Configure http server to only listen on known vhosts/IP

For the rest it returns 404

Fixes #446
This commit is contained in:
Girish Ramakrishnan
2017-10-26 21:50:16 -07:00
parent d127b25f0f
commit 3dedda32d4
3 changed files with 42 additions and 20 deletions

View File

@@ -4,6 +4,41 @@ map $http_upgrade $connection_upgrade {
'' close;
}
# http server
server {
listen 80;
<% if (hasIPv6) { -%>
listen [::]:80;
<% } -%>
<% if (vhost) { -%>
server_name <%= vhost %>;
<% } else { -%>
# IP based access. TODO: match the IPv6 address
server_name "~^\d+\.\d+\.\d+\.\d+$";
# collectd
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
# acme challenges
location /.well-known/acme-challenge/ {
default_type text/plain;
alias /home/yellowtent/platformdata/acme/;
}
<% } -%>
location / {
# redirect everything to HTTPS
return 301 https://$host$request_uri;
}
}
# https server
server {
<% if (vhost) { -%>
server_name <%= vhost %>;