My website is pretty messed up: it shows up as an IP address in the google search results (https). I want to redirect this to my domain, but when I couldn't figure out how to redirect https to my domain (I could only figure out how to redirect http). Here is my current nginx config file:
# Catchall configuration - redir to the domain for bare and invalid domain requests
server {
listen 80 default_server;
server_name _;
return 301 https://mosachi.ga$request_uri;
}
# HTTP handler to redirect to HTTPS for mosachi.ga
server {
listen 80;
server_name mosachi.ga;
return 301 https://mosachi.ga$request_uri;
}
# HTTPS for mosachi.ga
server {
listen 443 ssl;
server_name mosachi.ga;
ssl_certificate /etc/letsencrypt/live/mosachi.ga/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mosachi.ga/privkey.pem;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}