Score:0

Point domain to server without HTTPD

bb flag

I have a VM on Oracle Cloud Free tier and have the dedicated IPv4. I installed MariaDB on this server. I want to point the domain name (example.com) to that machine, in order to access the MariaDB with the domain, example to use example.com:3306 instead of xxx.xxx.xxx.xxx:3306 inside PHP code?

How can I do that without to install the nginx/apache httpd?

Score:0
cy flag
  1. First you login to whatever that gives you control over settings of example.com. Then you set up your nameservers properly: Here you can sign-up and use cloudflare as a free easy solution and use their nameservers for your domain (for example they might give you fay.ns.cloudflare.com and ara.ns.cloudflare.com). If you did that then it's time to add some DNS records: login to your cloudflare account and in the DNS section create an A RECORD (an ipv4 address) to point your @ (it means example.com without any subdomain) to your xxx.xxx.xxx.xxx. And it should work.

  2. In case you don't want to get your own domain and do all these name server stuff there is a local solution: You can tell your development machine that example.com should resolve to xxx.xxx.xxx.xxx. In Linux you do that by editing /etc/hosts file and appending this line:

xxx.xxx.xxx.xxx example.com

But be aware that the second solution only works for machines that have this kind of configuration and it is not global like previous one.

In either case you don't need to set-up any webserver. DNS is web-agnostic, it happens whether there is a webserver or not, or even the address belongs to a real server or it's just a random number.

In your case the thing is important is that the port be accessible from outside (configuring your firewall properly) and something is listening on it not just locally (127.0.0.1:3306) but also on xxx.xxx.xxx.xxx:3306. Usually you do that by listening 0.0.0.0:3306 with 0.0.0.0 as a wildcard to listen in all of them.

Nhân Trần avatar
bb flag
so you mean that, I just need to create A record in the domain control page and it should work?
Masood Lapeh avatar
cy flag
If your domain control page allows you to create an A record then do it and it should work. But if it only asks you for a name server (like mine), an easy, free, and flexible solution is to sign-up to cloudflare and enter their nameservers there (cf will tell you which ones). Then create an A record in cf's dashboard and you're good to go.
Score:0
in flag

A httpd is not necessary to run or access MySQL or MariaDB. If you don't want to run a webserver on the same machine, just don't install it.

You will need to configure MySQL to listen on the external interface (configure it to listen on 0.0.0.0), it defaults to the loopback interface. Don't forget to set permissions properly.

If necessary, open the TCP port of the database (in this case 3306) in the firewall/security groups and you are done. Ideally only allow your webservers to connect to it.

Nhân Trần avatar
bb flag
I want to set the domain for that machine. so that to connect to that machine's MariaDB, I will set the url example.com:3306 instead of <my id>:3306
in flag
Then do so. You do this at your domain registrar. You don't need anything on your server for that.
Score:0
us flag

If you open MySQL to external network, you need to be very careful about security:

  • Make sure the access to that server is limited, for example it is behind a firewall from public internet
  • If it has to be on public internet, configure TLS certificates and use TLS encryption when connecting to it
  • Make sure all user accounts have proper credentials
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.