I am using nginx on Ubuntu 18 for a reverse proxy and HTTPS tunnel to those localhost services. Here's my site config:
server {
listen 80;
server_name my.domain.com;
return 301 https://$server_name$request_uri;
}
server {
server_name my.domain.com;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000" always;
location /service1 {
proxy_pass http://localhost:8989;
proxy_set_header Host $host;
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 $scheme;
}
access_log /var/log/nginx/my.domain.com;
listen 443 ssl; # managed by Certbot
# Other certbot stuff for signed HTTPS certificate
}
Basically when I go to https://my.domain.com
, I don't want anything to show. I want it to be an error, as if the page doesn't exist. Right now it shows me "Welcome to nginx!". I have Googled ways of getting rid of it but I have had no luck. I completely disabled default
under /etc/nginx/sites-enabled
.
I only want nginx to serve https://my.domain.com/service1
and redirect HTTP to HTTPS, but I do not want any welcome pages to be served.
Something like this should work, near the existing location blocks.