I have installed WordPress on a LEMP stack in Ubuntu in Digital Ocean.
When I use the Droplet IP address to access it, it shows the default nginx welcome page; but when I use its URL, it shows the actual WordPress site that is installed on the site.
- What might be the issue?
- What is the best practice in terms of security?
Here's my nginx configuration:
# Redirect HTTP -> HTTPS
server {
listen 80;
server_name www.mysite.in mysite.in;
include snippets/letsencrypt.conf;
return 301 https://mysite.in$request_uri;
}
# Redirect WWW -> NON WWW
server {
listen 443 ssl http2;
server_name www.mysite.in;
ssl_certificate /etc/letsencrypt/live/mysite.in/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite.in/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/mysite.in/chain.pem;
include snippets/ssl.conf;
return 301 https://mysite.in$request_uri;
}
server {
listen 443 ssl http2;
server_name mysite.in;
root /var/www/html/mysite.in;
index index.php;
# SSL parameters
ssl_certificate /etc/letsencrypt/live/mysite.in/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mysite.in/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/mysite.in/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
# log files
access_log /var/log/nginx/mysite.in.access.log;
error_log /var/log/nginx/mysite.in.error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}