Route Godaddy Subdomain to AWS EC2 Nginx Config

This post contains the configurations for the godaddy subdomain to route to aws ec2 with nginx as web server and some configs added to take care of the direct refresh on the end urls.

In Godaddy, create the subdomain and redirect that to AWS EC2 Machine IP (Elastic IP) as A record like below,

This is the AWS EC2 installed nginx config for the subdomain setup. This file mostly presents in the /etc/nginx/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
    server {
        server_name  dashboard.ngdeveloper.com;
        root         /usr/share/nginx/html;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        error_page 404 /404.html;
        location = /404.html {
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/dashboard.ngdeveloper.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/dashboard.ngdeveloper.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
                location / {
                     try_files $uri $uri/ /index.html;
                }
      }

       server {
        listen 80;
        server_name dashboard.ngdeveloper.com;
        return 301 https://dashboard.ngdeveloper.com$request_uri;
       }


        # dashboard.ngdeveloper.com - 443
      server {
                listen 443 ssl;
                server_name dashboard.ngdeveloper.com;
    ssl_certificate /etc/letsencrypt/live/dashboard.ngdeveloper.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/dashboard.ngdeveloper.com/privkey.pem; # managed by Certbot
                return 301 https://dashboard.ngdeveloper.com$request_uri;

        }
}

3 comments

  • Alissa2933

    Элвис Пресли, безусловно, один из наиболее влиятельных музыкантов в истории. Родившийся в 1935 году, он стал иконой рок-н-ролла благодаря своему харизматичному стилю и неповторимому голосу. Его лучшие песни, такие как “Can’t Help Falling in Love”, “Suspicious Minds” и “Jailhouse Rock”, стали классикой жанра и продолжают восхищать поклонников по всему миру. Пресли также известен своими выдающимися выступлениями и актёрским талантом, что сделало его легендой не только в музыке, но и в кинематографе. Его наследие остается живым и вдохновляет новые поколения артистов. Скачать музыку 2024 года и слушать онлайн бесплатно mp3.

  • This stage is incredible. The magnificent information uncovers the manager’s excitement. I’m shocked and anticipate additional such mind blowing substance.

  • This post is a testament to your skill as a writer and thinker.

Leave a Reply