http://www.perlmonks.org?node_id=11122389

Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:

I've never had a VPS before a fortnight ago, so I have yet to figure out much of the functionality. Also not sure how much of my question is vendor-specific. I've gotten so far as to get my domain out out the registrar's (ionos') purgatory and have the nameservers pointing to DO. Then, I sit there looking at the records page and wonder if I have more to do there...or not. (can't share the page.)

It has a table with these values along the top:

A AAAA CNAME MX TXT NS SRV CAA

This is the explanation for A:

Use @ to create the record at the root of the domain or enter a hostname to create it elsewhere. A records are for IPv4 addresses only and tell a request where your domain should direct to.

Do I fiddle with this menu, creating a 'record', or do I get what I need by creating-apache-virtual-hosts-on-ubuntu? I've done this before to my home machine, but to put it bluntly, do I need to create a virtual host on a virtual host?

I've been looking at the host command to see if it tells me anything relevant:

$ host -t soa www.merrillpjensen.com www.merrillpjensen.com has SOA record ns1.digitalocean.com. hostmaster +.www.merrillpjensen.com. 1601009638 10800 3600 604800 1800

The meaning of Start of Authority data seems to deal with varying measures of time. (1601009638 doesn't make sense to me as the first four numbers are to represent YYYY, and nothing happened in 1601 except that life was nasty, brutish, and short.)

$ host -v www.merrillpjensen.com Trying "www.merrillpjensen.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53474 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.merrillpjensen.com. IN A Received 40 bytes from 127.0.0.53#53 in 15 ms Trying "www.merrillpjensen.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56934 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.merrillpjensen.com. IN AAAA Received 40 bytes from 127.0.0.53#53 in 14 ms Trying "www.merrillpjensen.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57522 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.merrillpjensen.com. IN MX Received 40 bytes from 127.0.0.53#53 in 15 ms $

My goal for this thread is to get "hello mojo world" to display. I'd like to know whether I'm doing the right thing before I do the next thing.

Thank you for your comment,

Replies are listed 'Best First'.
Re: [OT] Next steps in using DigitalOcean to host a website running Mojolicious
by Discipulus (Abbot) on Oct 01, 2020 at 07:20 UTC
    Hello Aldebaran,

    > 1601009638 doesn't make sense to me as the first four numbers are to represent YYYY, and nothing happened in 1601 except that life was nasty, brutish, and short

    ..yes but in XVII century was easier to be hosted :)

    the number you see there is the last modification of the SOA record, a classic UNIX timestamp

    print scalar gmtime(1601009638)#Fri Sep 25 04:53:58 2020

    You generally need an A record to make a name of your domain resolving into the IP of your VPS. Then you must configure Apache on the VPS to answer to that hostname (virtualhost).

    DNS resolution are cached by clients so, once you put the A record it needs some time to propagate (you can check it here for example).

    I'd modify the title of your post as off-topic: [OT]  Next steps in using DigitalOcean to host a website running Mojolicious

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      You generally need an A record to make a name of your domain resolving into the IP of your VPS. Then you must configure Apache on the VPS to answer to that hostname (virtualhost).

      Thx, Disciplus, your directions got me on the scoreboard. What's more, I was able to use a perl script on my laptop to create a sample translation, but it fails to create a directory for images.

      DNS resolution are cached by clients so, once you put the A record it needs some time to propagate (you can check it here for example).

      I couldn't quite understand this. Can you say a few more words about it?

      I'd modify the title of your post as off-topic:

      It's diplomatic of you to use the first person subjunctive. What this brings to mind for me is what Sawyer X was talking about at the conference. He created a handful of profiles of people who use the perl programming language contemporaneously.

      There was a profile of user that I would have added to that: the 'Bill Ford' user, an amalgam of the people I knew from usenet. This would be a person on the faculty, in a thinktank, nasa, maybe embedded...who has personal pet projects that get held together by perl. So it is that these guys would have 20% perl in a lot authentic tasks that get down and dirty with compilers and numerical computations.

      I think perl is the 20% that gets a lot of hybrid tasks accomplished. Or, I imagine perl as the octopus that can pour itself through every crack, but operates natively on unix. (Stick with one metaphor, right).

      This topic might be one of those 20 percenters that a 20 percenter might have. There was a lot of talk about hosting situations at the conference, and because of those presentations I took this path, and I am a straight-up Firstie with "going virtual." It's closer to doing sysadmin stuff than I've ever been, so it's the direction I want go. Isn't sysadmin stuff Almost on-Topic? (maybe it could be like horseshoes)

      Anyways, I'm not here to cause trouble or wreck the place....

Re: [OT] Next steps in using DigitalOcean to host a website running Mojolicious
by parv (Vicar) on Oct 01, 2020 at 07:36 UTC
Re: [OT] Next steps in using DigitalOcean to host a website running Mojolicious
by 1nickt (Abbot) on Oct 01, 2020 at 12:12 UTC
      This is not a Perl question.

      It seems to be a "getting to the perl" question.

      See the docs provided by your host: https://www.digitalocean.com/docs/networking/dns/how-to/manage-records/.

      I stared at those pages for hours, days. The couple hints I got here imparted courage to try something, at least. When I view that page whilst signed in now, the domain information makes more sense, because it's particular.

      "My goal for this thread is to get "hello mojo world" to display" Does it do that in your local, test environment?

      Yes, and your question made me think long and hard about that local, test environment, and how it should have directory hierarchies similar to the target. I've got local and remote results, so super happy about that:

      fred@fourth:~/mojo$ mojo generate lite-app 1.myapp.pl [exist] /home/fred/mojo [write] /home/fred/mojo/1.myapp.pl [chmod] /home/fred/mojo/1.myapp.pl 744 fred@fourth:~/mojo$ ll total 20 drwxrwxr-x 2 fred fred 4096 Oct 13 20:29 ./ drwxr-xr-x 9 fred fred 4096 Oct 13 20:29 ../ -rwxr--r-- 1 fred fred 388 Oct 13 20:29 1.myapp.pl* -rwxr-xr-x 1 fred fred 127 Oct 13 19:12 2.1.mojo_hello.pl* -rwxr-xr-x 1 fred fred 1925 Oct 13 18:41 5.2.elev.pl* fred@fourth:~/mojo$ ./1.myapp.pl daemon [2020-10-13 20:30:50.55473] [75108] [info] Listening at "http://*:3000 +" Web application available at http://127.0.0.1:3000 [2020-10-13 20:31:02.55218] [75108] [debug] [XY-c4b0j] GET "/" [2020-10-13 20:31:02.55290] [75108] [debug] [XY-c4b0j] Routing to a ca +llback [2020-10-13 20:31:02.55381] [75108] [debug] [XY-c4b0j] Rendering templ +ate "index.html.ep" from DATA section [2020-10-13 20:31:02.55514] [75108] [debug] [XY-c4b0j] Rendering templ +ate "layouts/default.html.ep" from DATA section [2020-10-13 20:31:02.55639] [75108] [debug] [XY-c4b0j] 200 OK (0.00419 +6s, 238.322/s) ^Cfred@fourth:~/mojo$ cat 1.myapp.pl #!/usr/bin/env perl use Mojolicious::Lite -signatures; get '/' => sub ($c) { $c->render(template => 'index'); }; app->start; __DATA__ @@ index.html.ep % layout 'default'; % title 'Welcome'; <h1>Welcome to the Mojolicious real-time web framework!</h1> @@ layouts/default.html.ep <!DOCTYPE html> <html> <head><title><%= title %></title></head> <body><%= content %></body> </html> fred@fourth:~/mojo$

      Thanks all for replies.

Re: [OT] Next steps in using DigitalOcean to host a website running Mojolicious
by atcroft (Abbot) on Oct 02, 2020 at 04:55 UTC

    A VPS (Virtual Private Server) behaves as if it were a physical server under your control, but is likely some form of virtualized server (such as VMWare, Xen, etc.) that (likely) limits the blast radius of any damage you might do.

    You can create a virtual host in your web server before you put entries in DNS. A partial list of methods you can use to test if the virtual host is working include setting a browser's proxy settings to use the virtual host's IP, or connecting directly to TCP port 80 or 443 (for HTTP or HTTPS, respectively) via telnet (for HTTP) or openssl (for HTTPS) or another appropriate program. (Connecting directly requires you to understand a little more about what happens under the hood of a web browser (although this can be learned by browsing through "Web Client Programming with Perl", available through the O'Reilly Open Books Project, or the appropriate RFCs).)

    Regarding DNS, each record type has a particular meaning, and some of those are not necessary. Most people, in fact, probably only deal with SOA, NS, A/AAAA, MX, and possibly TXT, CNAME and CAA. (The last is actually new for me, since the time I last did DNS administration in a professional capacity.) (If you want to get deeply into DNS, I strongly recommend whatever the current version of "DNS and BIND" (sometimes referred to as the "Grasshopper" book) is from O'Reilly. And no, they don't pay me to advertise. :) )

    Here is a sample zone file in BIND syntax for example.com:

    $ORIGIN example.com. ; All unqualified names relative to this domai +n. $TTL 86400 ; default time to live @ IN SOA ns.icann.org. noc.dns.icann.org. ( 2020091009 ; Serial - 2020-09-10, change 9 7200 ; Refresh - 2 hours (7_200s) 3600 ; Retry - 1 hour (3_600s) 1209600 ; Expire - 14 days (1_209_600s) 3600 ; Minimum TTL - 1 hour (3_600s) ) ; Could also be written as a single line with no parens. IN NS a.iana-servers.net. IN NS b.iana-servers.net. IN MX 0 . IN A 93.184.216.34 IN AAAA 2606:2800:220:1:248:1893:25c8:1946 ; Three CAA examples from RFC6844. IN CAA 0 issue "ca.example.net; account=230123" IN CAA 0 iodef "mailto:security@example.com" IN CAA 0 iodef "http://iodef.example.com/" bar IN CNAME foo foo IN TXT "Hello, world." www IN A 93.184.216.34 www.example.com. IN AAAA 2606:2800:220:1:248:1893:25c8:1946

    SOA (start or source of authority) records define the domain name, a mailbox for a person responsible for the domain (with the '@' replaced with a '.' (I can't recall having actually had someone contact me using that, but it is required by the spec), a serial number to determine if the domain has been updated, and time values (in seconds) for refresh, retry, and expire and minimum TTLs (times-to-live). Your confusion regarding the serial number is because there are basically three camps when it comes to serial numbers: 1) those who use a YYYYMMDDnn value, as was the recommendation in "DNS and Bind", 2) those who use epoch seconds (a.k.a. *nix timestamp), and 3) those who start at 1 and increment with each change. Personally, I don't think it matters which you use for now, as long as you stick with whichever scheme you select. Changing from one to another is a bit of a process) The refresh, retry, expire, and minimums are used by well-behaved DNS resolvers to determine how long to keep information (although a resolver can override those values in some cases).

    A few quick notes. '@' refers to the zone name. An entry ending in a period ('.') is considered an absolute name (such as 'www.example.com.'), whereas an entry not ending with a period is relative to the zone or last $ORIGIN directive (thus 'www' is 'www.example.com.'). Anything following semicolons (';') is considered a comment (unless in a quoted string, as in the first CAA record in the example above). The $ORIGIN directive sets the domain name for unqualified records. The $TTL directive sets the default TTL (time-to-live) for records. BIND now allows times to be written in formats using combinations of 'w' (605_800s), 'd' (86_400s), 'h' (3_600s), 'm' (60s), and 's' (1s), so one could write a time of '1w2d3h4m5s' instead of 788_645 seconds (if desired). Entries that begin with a blank apply to the previous named host.

    Next are the NS (name server) record(s) declare which DNS servers should be considered as authoritative for a particular domain. Those should include at a minimum the DNS server(s) listed with the registrar, but can include others for redundancy. (Also, those servers should actually hold DNS information for your domain, or know to retrieve and serve such.)

    A and AAAA are address records. A records associate an IPv4 address to a name; AAAA records an IPv6 address. You can have multiple A and/or AAAA records associated with a name (which means any one of them can receive traffic for that name), and you can have multiple names associated with a single IP (v4 or v6) address (meaning any one of the names will try to reach that address). (Multiple names resolving to an address is where virtual hosting on a web server comes into play.)

    MX (mail exchange) records indicate the hosts that can receive mail for the domain. These records also include a priority, with the preference to the lower priority value. The intention is that hosts with a higher priority value can accept the mail, then attempt delivery to the host(s) with a lower priority.

    CNAME (canonical name) records are, in effect, aliases. In the example above, a lookup for 'bar.example.com.' will return the record for 'foo.example.com.' CNAMEs have limitations. They can only point to host or domain name. If a CNAME is present for a name, there can be no other records for that name to ensure canonical and alias values do not differ. (Apparently there is an exception for DNSSEC-related records, but that is outside the scope of this text.) MX and NS records and domains used in SMTP MAIL and RCPT commands must never point to a CNAME alias. CNAMEs should not point to other CNAMEs, as this can result in excessive lookups and even unresolvable loops. Because of these limitations, it is generally best to avoid the use of CNAMEs unless you understand why they are appropriate.

    CAA (certification authority authorization) records specify the certificate authorities (CAs) that are authorized to issue digital certificates for a particular domain name. This came about following several incidents from 2001 onward where a certificates were obtained through a CA by unauthorized parties. CAA records are one of several mechanisms developed to limit mis-issuance by CAs. If CAA records exist for a domain, a CA is to check if they are permitted to issue certificates for that domain. ("issue" permits the holder of the domain in the property value to issue certificates for this domain. "iodef" refers to methods of reporting invalid certificate requests using the Incident Object Description Exchange Format.)

    TXT (text) records allow for arbitrary text to be associated with a host. This can be used for notes, or some services (such as SPF, DKIM, and DMARC policies, among others).

    Hope that information was helpful. (And please let me know if there are any errors.)

      (Connecting directly requires you to understand a little more about what happens under the hood of a web browser (although this can be learned by browsing through "Web Client Programming with Perl", available through the O'Reilly Open Books Project, or the appropriate RFCs).)

      Thanks for your extended comments, atcroft, they helped me to get over the hump here. That book is definitely worth reading and bookmarking. Regarding VPS's, a super search revealed Is it Perl problem or VPS problem? and Move Perl modules to new CentOS VPS, good for background.

      A few quick notes. '@' refers to the zone name.

      I really don't know how to disambiguate the @'s in this business yet. What ended up working for me was, for the A tab, putting the @ in the left window and 'fourth' on the right, the alias for my IP address. I did the same with AAAA, and then all the records look like this:

      DNS records Type Hostname Value TTL (seconds) AAAA www.merrillpjensen.com directs to 2604:a880:4:1d0::78:2000 3600 A www.merrillpjensen.com directs to 164.90.158.33 3600 NS www.merrillpjensen.com directs to ns2.digitalocean.com. 1800 NS www.merrillpjensen.com directs to ns3.digitalocean.com. 1800 NS www.merrillpjensen.com directs to ns1.digitalocean.com 1800

      To be very honest, I don't understand these mappings at all. Indeed, the NS ones seem to be backwards to me. (?)

      Here is a sample zone file in BIND syntax for example.com:

      I actually tried to look this up and found something rather interesting. I couldn't figure out how a person comes by such data for any given site.

Re: [OT] Next steps in using DigitalOcean to host a website running Mojolicious
by perlfan (Vicar) on Oct 01, 2020 at 14:22 UTC
    Bare minimum is to set up the A record that points the domain name(s) to the IP address of your instance. With mojo (like dancer2), there is no need to install Apache. Each has it's own http service for testing. As long as the A record is set up, you just point your browser to it (http, not https - no need to bother with that yet): http://mydomain.tld:$port. Both work great behind a proxy (starman, nginx). You can specify the port (e.g., 80), but their defaults are non-standard. If you're going to be hosting different domains, then use something like nginx or haproxy as the "reverse proxy" (haproxy is my personaly preference) but it's truly up to you. Other capable reverse proxies exist as well. Although apache handles this very well, my recommendation is to stay as far away from it as possible due to it being a pain in the ass to manage and 1,000x more than what you (or most of us) want or need.