0

I built a rails app in ec2 instance and deployed using route 53.

Currently I succeeded in associating the instance with the domain provided by amazon.

I can access to the page with the domain name.

However, once I create a record and associate the domain to the alb, I'm no longer able to access to the page.

I'm doing it to make the https access available.

I checked the things below.

  • Target group succeeds health check
  • Typing the DNS name of ALB works with both http and https
  • The record on route53 shows the DNS name above
  • The security group used for the ALB allows all the access regardless of either http or https
  • listener is configured for both http and https

I also checked the article below

I have no idea of what else to check after all.

Please help me.

I've been working on this the whole day...

Here's my config files

ruby_gems_bootcamp.conf(for nginx)

;; Query time: 6 msec
# log directory
error_log /var/www/rails/ruby-gems-bootcamp/log/nginx.error.log;
access_log /var/www/rails/ruby-gems-bootcamp/log/nginx.access.log;

# max body size
client_max_body_size 2G;
upstream app_server {
        # for unix domain socket setups
        server unix:/var/www/rails/ruby-gems-bootcamp/tmp/sockets/.unicorn.sock fail_timeout=0;
}

server {
    listen 80;
    server_name 54.248.194.243

    # nginx so increasing this is generally safe ...
    keepalive_timeout 5;

    # path for static files
    root /var/www/rails/ruby-gems-bootcamp/public;

    # page cache loading
    try_files $uri/index.html $uri.html $uri @app;

    location @app {
            # http headers
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            # referring upstream app_server
            proxy_pass http://app_server;
    }

    # Rails error pages
    error_page 500 502 503 504 /500.html;
    location = /500.html {
            root /var/www/rails/ruby-gems-bootcamp/public;
    }
}

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 {
        listen       80;
        listen       [::]:80;
        server_name  _;
        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 {
        }
    }
}

route53 configuration

enter image description here

  • 2
    How did you configure Amazon Route 53 to use the Application Load Balancer? Please Edit your Question to show how you configured it. – John Rotenstein Aug 20 '21 at 10:29
  • Thank you so much for the comment John :) I attached my nginx conf code and the image of a record information. Is this what you meant? If not, please tell. I add more information. – Yoshihisa Okada Aug 20 '21 at 10:36
  • 2
    It works perfectly fine for me. When I go to `https://alb-2.yoshihisaokada.net/`, your website appears. I am in Australia. – John Rotenstein Aug 20 '21 at 10:39
  • Ahhhhhhhh!!!! Now it makes sense! It was so simple. What's wrong was that I've been trying to access with just yoshihisaokada.net. I should have added alb-2. I totally misunderstood how route53 works. Thank you so much John! You saved my day!!! – Yoshihisa Okada Aug 20 '21 at 10:44

0 Answers0