Friday, 24 March 2017

Can't resolve DNS Aws

I recently registered a domain for a joke website  I figured I could whip up the page in a couple of minutes and throw it up on AWS using S3 static site hosting.  All done in an hour or so. What I thought would take an hour ended up in a multi-day ordeal while I tried to get the DNS to resolve.  I went through what seem to be the typical problems.
  • The bucket wasn't configured to be accessible as a website.
  • My bucket wasn't named the same as the website; the bucket needed to be to match the domain
I got these fixed up and found that it still wasn't working.
 I added extra routes in to see if I could Alias or CNAME to a known working site, but they didn't work either. So it seemed it was a problem with something to do with the DNS configuration.

After searching around I found a mention in a thread that the name server records in the hosted zone needed to match those in the domain name registration.  In attempting to get the hosted zone to recognise the bucket I had deleted the one created by default when I registered the domain.  The new hosted zone did not have matching name servers to the domain name.  I updated the domain's name servers to match that of the hosted zone, and BAM! name resolution.

So in the end I needed to make sure that the domain name servers:
Route 53 > Registered domains >

matched those in the hosted zone:
Route 53 > Hosted zones >

Sunday, 5 March 2017

Solving `Empty reply from server` in DotNet Core


If you’re getting curl: (52) Empty reply from server check that you’ve configured Kestrel correctly.

Long version

I’ve started playing with Dotnet Core and Docker and have had a few issues getting started. I’ve had a little bit of experience with Docker, though only a little. I’ve worked with DotNet previously but never with Core.


The setup I’m using is a Windows laptop running Vagrant. Via Vagrant I’m running an Ubuntu Virtual Machine with the Docker run time installed. Feels a litle like inception.

Key Problem

The key problem that I’ve had getting started was having my Docker container not responding correctly to my curl commands. I get this:
curl: (56) Recv failure: Connection reset by peer
curl: (52) Empty reply from server
Given that I’m not all that familliar with Docker or Dotnet Core I decided to remove one of the variables and set up a simple Express app in a different docker container. This validated that the commmand I was using to run the container (docker run -v /vagrant/dotnetcoretest/src:/src -p 5000: 5000 -d dnctest dotnet run) was binding the ports correctly.
This left a problem with the Dotnet Core web api app. I was surprised that this would be the problem given that I had created the app with the dotnet new webapigenerator.
Searching around I found that the problem was that by default Kestrel listens on localhost:5000. To fix this add .UseUrls("http://*:5000") to the WebHostBuilder in Program.cs. It should now look like
public class Program
    public static void Main(string[] args)
        var host = new WebHostBuilder()

Rebuild the app and run curl localhost:5000/api/values and you should get ["value1","value2"].