Resolved: Adding MX Record(s) in AWS

 Recently, I was migrating MX records from WIX to AWS. I was using GSuite and I was unable to do the same. Then after a little bit of research, I found this stackoverflow link , which helped me resolve the problem. Here is how you should be adding the records in AWS. Record Name: @ Record Type: MX Value: <Priority> <Route Traffic to> example: 10 aspx.alt1.google.com And if you have multiple records, simply add the records in the same text area in the new line and no commas. This will resolve your problem. :)

Setting up your VPS for .Net Core self hosting - Part 1

Ever wondered, how can you set up a cost-effective Virtual Private Server for .Net Core hosting? 

In this blog, I am discussing how to set up your own VPS for .Net Core self-hosting. 

Here are the steps:

  1. Set up an Ubuntu Server
  2. Install Asp.Net Core runtime
  3. Install Nginx
  4. Upload your published files in a folder on the server
  5. Configure nginx to receive and forward requests to the Kestrel Server
  6. Reload nginx config so that nginx reads the latest config
  7. Are you getting 502?
  8. Run the dll
  9. yay!

1. Setup an Ubuntu Server

I have set up an AWS Lightsail Server. You can follow this video to do the same.

2. Install Asp.Net Core runtime

I have followed this link for that:

Since I have Ubuntu20.x, the only commands that I ran to install dotnet core runtime are:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-3.1

To verify dotnet runtime run "dotnet --info"

3. Install Nginx

I have followed this link to install nginx and the only commands I ran were:
sudo apt-get update 
sudo apt-get install nginx

4. Upload published files to the server

Ideally, I recommend using Azure Pipelines which should own the responsibility of building the package and publishing the files on the server. For this demo, you can follow video in step 1 to upload the files using FTP.

5. Configure nginx to receive and forward requests

  • Run `sudo nano  /etc/nginx/sites-available/default`
  • Modify the contents of as below (Replace the text in <> with your own values):
    server {
            listen 80;
    #       listen [::]:80;
    #
            server_name ;
    #
            root /var/www/;
    #       index index.html;
    #
            location / {
                    proxy_pass http://localhost:5000;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection keep-alive;
                    proxy_set_header Host $host;
                    proxy_cache_bypass $http_upgrade;
            }
    }

6. Reload nginx config so that nginx reads the latest config

Run `sudo nginx -s reload`

This command makes nginx read the latest configuration

7. Are you getting 502 Bad Gateway?

At this time, if you are getting bad gateway, then you should look in /var/log/nginx/error.log and you would get to know that you have not run the dll yet.

8. Run your dotnet application

Run the command in the directory where your files are available `dotnet <your dll>`

9. Check your website again. It should work fine. 

If your application did not work fine, please comment the issue that you are facing. I'll try my best to help you out. You have hosted a .Net Core application on your own VPS.

Next Steps?

We'll talk in the next blogs about running the dotnet application as a service and lot more. So, stay connected. 😊