Nginx – Pointing Custom Domain to Server on Nginx

azurecname-recordnginxphusion-passengerruby-on-rails

I have my server up and running on an Azure Ubuntu 14.04 virtual machine. It is working great. Now I want to point my custom domain to it so that users can visit my website by going to www.example.com instead of www.example.eastus.cloudapp.azure.com.

I changed the DNS settings on my domain registrar by setting a CNAME with the following settings:

Name: www

Value: example.eastus.cloudapp.azure.com

My website at www.example.com is showing the "Welcome to nginx on Ubuntu!" configuration page, while my Azure domain is correctly showing my application. Here's my Nginx configuration (I'm using Passenger with Rails):

server {
    listen 80;
    server_name example.eastus.cloudapp.azure.com;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /var/www/example/code/public;

    # Turn on Passenger
    passenger_enabled on;
    passenger_ruby /home/example/.rvm/gems/ruby-2.1.5/wrappers/ruby;
}

I've done a lot of searching and can't seem to find out what's missing. I thought that changing the CNAME in my DNS settings would be enough to get this to work.

Any insight would be greatly appreciated!

Best Answer

Your server_name needs to match the CNAME record you created, not the target of the CNAME.

Related Topic