Link subdomain on NearlyFreeSpeech to my Linode box?

I have a domain somedomain.com registered with Namecheap. NearlyFreeSpeech hosts the site.

I've added ns.phx1.nearlyfreespeech.net and
ns.phx2.nearlyfreespeech.net to that domain's custom nameservers
list on Namecheap.

I'd like to add a subdomain
"test" so that test.somedomain.com goes to my Linode box. Where must I change/add records to accomplish this?

22 Replies

I added A and AAAA records to my NearlyFreeSpeech DNS settings.

My A record looks like this, for instance.

test.somedomain.com A MY.IP.ADDRESS.HERE

Yeah that's pretty much all correct, assuming that your domain is now using the nearlyfreespeech nameservers as its authoritative ones. You can do a dig +trace your.domain to confirm that.

But when I go to test.somedomain.com, I get a Bad Request (400) error.

That doesn't have anything to do with DNS. That's a web server issue.

Have you actually configured nginx, Apache or whatever you're using to serve that domain?

I'm using nginx. I followed Linode's tutorial on setting up a Django project on an Ubuntu 14.04 box.

Maybe I configured the hostname file wrong?

Here's what's in my /etc/hosts:

127.0.0.1       localhost.localdomain   loclhost
127.0.1.1       ubuntu.members.linode.com       ubuntu
MY.LINODE.IP.ADDRESS    dev.somedomain.com       dev

I wouldn't get hung up on the /etc/hosts file too much (though localhost is misspelled).

What does your nginx server block config look like? Also, this would be a lot easier if you just gave me the domain name..if it's on the internet it's not exactly private anyway.

Sure, the domain is richblockspoorblocks.com. Thanks for catching the typo. Where do I find the nginx server block config?

I guess I should have asked for the specific subdomain - I can open richblockspoorblocks.com, but that's pointing to the nearlyfreespeech IP.

So, what is the specific subdomain you're trying to configure?

On Ubuntu, your individual configs should be under /etc/nginx/sites-enabled. I'd just throw any configs you find in there into code blocks here.

I want to make test.richblockspoorblocks.com point to my Linode box.

Here's the contents of one config file called product_blog.

server {
    listen 80;
    server_name richblockspoorblocks.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/django/product_blog;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/home/django/product_blog/product_blog.sock;
    }
}

Ok you've got a few issues, then:

  • You don't have a DNS A record configured (or, properly configured) to point to your Linode's IP:
dig test.richblockspoorblocks.com @ns.phx1.nearlyfreespeech.net

; <<>> DiG 9.10.3-P4-Ubuntu <<>> test.richblockspoorblocks.com @ns.phx1.nearlyfreespeech.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 48801
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test.richblockspoorblocks.com.    IN  A

;; AUTHORITY SECTION:
richblockspoorblocks.com. 180    IN  SOA ns.phx1.nearlyfreespeech.net. hostmaster.nearlyfreespeech.net. 1525886283 600 180 86400 180

;; Query time: 61 msec
;; SERVER: 2607:ff18:80:53::1#53(2607:ff18:80:53::1)
;; WHEN: Wed May 09 15:46:40 EDT 2018
;; MSG SIZE  rcvd: 133

I don't know anything about nearlyfreespeech's DNS offering - you may want to reach out to their support / community to confirm that your record is set up correctly.

  • You want the server_name directive in your config to match the address that you're using for your record - so when someone enters test.richblockspoorblocks.com into their browser, the DNS lookup points them to your Linode's IP, and then your web server uses the domain being requested to determine what content to serve. So you would want to update the server_name value to `test.richblockspoorblocks.com;``

I changed server_name value to test.richblockspoorblocks.com; and ran sudo service nginx configtest && sudo service nginx restart. So far, still a 400 error. My A record is on NearlyFreeSpeech's DNS, not Linode's, by the way. Do I need it on both?

I'm not able to find that that record exists one nearlyfreespeech's nameservers. In the example above, I queried their nameservers directly for a record for that domain, and it didn't return anything. I'm not sure how you're getting a 400 error. How are you receiving the error? You're entering test.richblockspoorblocks.com into a browser on your local machine?

You do not need to host your DNS with Linode to point domains to their IPs.

Strange. I'll ask NearlyFreeSpeech about it.

How are you receiving the error? You're entering test.richblockspoorblocks.com into a browser on your local machine?

Yes. Do you also see a 400 error when you enter the URL on your machine?

Oh hey looks like it's working now:

nslookup test.richblockspoorblocks.com ns.phx1.nearlyfreespeech.net
Server:        ns.phx1.nearlyfreespeech.net
Address:    2607:ff18:80:53::1#53

Name:    test.richblockspoorblocks.com
Address: 45.33.74.118

So now I'm also getting that 400 bad request. Progress.

NearlyFreeSpeech customer support on the 400 error:

it is not a
DNS error. This would indicate that your DNS is fine but your Linode is
configured improperly.

I wonder what else I need to fix on my Linode if that's the case…

I would take a look at your nginx error log. It should be located under /var/log/nginx.

That directory has two files: access.log and error.log. In the first file, here are the last two access attempts from my just now with my local machine's IP redacted.

MY.IP.ADDRESS - - [09/May/2018:17:12:23 -0400] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36"
MY.IP.ADDRESS - - [09/May/2018:17:12:51 -0400] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36"

No recent errors in the second file, just one from Saturday. That error prevented the site from loading at all when I'd navigate my browser to my Linode's IP, but I fixed it.

2018/05/05 23:19:40 [crit] 10030#0: *8 connect() to unix:/home/django/RBPB2/RBPB2.sock failed (2: No such file or directory) while connecting to upstream, client: 52.27.2.86, server: richblockspoorblocks.com, request: "GET /86988246830.html HTTP/1.1", upstream: "uwsgi://unix:/home/django/RBPB2/RBPB2.sock:", host: "offcu.com"

Make sure you're running NGINX in debug mode with a debug log to get more details on why it's throwing 400 errors in response to URL requests. Here's a link w/instructions on how to set this up:

NGINX debugging log

Thanks for the advice, Ben. In which directory do I run these commands?

./configure --with-debug ...
error_log /path/to/log debug;

I added error_log /var/log/nginx/debug.log debug; to /etc/nginx/sites-available/mySite

I ran sudo service nginx configtest && sudo service nginx restart then navigated my browser to test.richblockspoorblocks.com. Still get a 400 error. But in the debug.log is a bunch of lines. Here's a Pastebin.

I ran sudo reboot and sudo service nginx configtest && sudo service nginx restart. Now the site loads just fine. I don't know which of those two commands did it.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct