How to solve IP canonicalization in Nginx?
ls /etc/nginx/sites-enabled
WordPress
cat /etc/nginx/sites-enabled/wordpress
ServerName mysite.com
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I have this question too, but I already run more than one site. I do have a file in sites available title digitalocean and this is the key part I tried to make it like your example above.```server { listen 80 default_server; listen [::]:80 default_server;
root /usr/share/nginx/html/index.html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _ localhost 138.xxx.x.x;
return 403;
the ip address doesnt serve anything which I dont think is good.
Make sure server_name is set to mysite.com and that the listen line doesn’t contain default_server in /etc/nginx/sites-enabled/wordpress.
Then, add a new virtualhost called default with the following config:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 403;
}
Finally, restart nginx:
sudo service nginx restart
This should make sure your site is served only when you’re accessing it using the domain name. The IP address will just return a 403 Forbidden error.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.