For security, I think it would be better if by default Discourse forums aren’t visible when navigating directly to the IP address in a browser.
A couple of reasons:
- Allows use of site without HTTPs, for users and also the initial configuration by the admin.
- Leaks origin server address, which is bad if you’re using cloudflare or similar to protect your origin IP from ddos attacks or server hacking attempts, if the hackers deem the server to be of high value. There are people out there running bots scanning all IP ranges owned by webhosts.
Also, the discourse installer now confirms that the domain/subdomain is configured properly or it won’t continue with the install.
All that needs to be added to the very bottom of the /etc/nginx/conf.d/discourse.conf file (inside the docker container) is:
server {
listen 80;
server_name 1.1.1.1;
server_tokens off;
return 404;
}
Where 1.1.1.1 is your server’s public IP address. There is probably a more elegant way to include the IP address than hard coding it. I tried a couple but couldn’t get them working.
Works well for me (including with cloudflare proxying), I can’t think of many cases where allowing web access directly on the IP would be useful or necessary. It seems like fairly common practice to disallow this. Happy to hear any reasons not to do this though!