skip to Main Content

I just Deployed a website on AWS EC2 from github clone. When i visit to Influencer Marketing & Career pages the server serving the static files from S3 Bucket correctly. But when i am visiting my home page & Who are We pages its not serving the static files also i am not getting these pages contents (raw data). I assume that its not serving static files its ok but where is the content of both pages gone. What i am missing here. I am new to AWS and Website deployment So if i did any mistake please let me now i will correct it. If you require any additional information i will add it.

Configure Nginx to Proxy Pass to Gunicorn

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/try-django-digital-marketing/try-django-digital-marketing
ExecStart=/home/ubuntu/try-django-digital-marketing/try-django-digital-marketing/env/bin/gunicorn 
          --access-logfile - 
          --workers 3 
          --bind unix:/run/gunicorn.sock 
          BE.wsgi:application




server {
    listen 80;
    server_name 3.17.142.65;

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

Bucket Policy, Cross-origin resource sharing (CORS) & User Policy

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::try-marketing/*"
        }
    ]
}

__________________________________________________

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "POST",
            "GET",
            "PUT"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]

___________________________________________________

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:AbortMultipartUpload"
            ],
            "Resource": [
                "arn:aws:s3:::try-marketing",
                "arn:aws:s3:::try-marketing/*"
            ],
            "Effect": "Allow"
        }
    ]
}

AWS Conf file

AWS_USERNAME = 'user11111'
AWS_ACCESS_KEY_ID = 'xxxxxxxxxx' 
AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxxxx' 
AWS_PRELOAD_METADATA = True
AWS_QUERYSTRING_AUTH = False
AWS_S3_SIGNATURE_VERSION = "s3v4"
AWS_S3_REGION_NAME = 'us-east-2'
DEFAULT_FILE_STORAGE = 'BE.aws.utils.MediaRootS3BotoStorage'
STATICFILES_STORAGE = 'BE.aws.utils.StaticRootS3BotoStorage'
AWS_STORAGE_BUCKET_NAME = 'try-marketing'
S3DIRECT_REGION = 'us-east-2'
S3_URL = '//%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
MEDIA_URL = '//%s.s3.amazonaws.com/media/' % AWS_STORAGE_BUCKET_NAME
MEDIA_ROOT = MEDIA_URL
STATIC_URL = S3_URL + 'static/'
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
AWS_DEFAULT_ACL = None

2

Answers


  1. I don’t see the images even being requested on your home page. That indicates a problem in your HTML source (it is not interpreted correctly by the browser). I would suggest to you to fix the issues identified by the W3 validator https://validator.w3.org/nu/?doc=http%3A%2F%2F3.17.142.65%2F
    and see if it helps.

    Login or Signup to reply.
  2. did a bit of reverse engineering on your website….. some of your are missing in the pages that are not serving the static file

    add this to the header section of the pages that are not serving the static file

        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/bootstrap.min.css'>
        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/font-awesome.min.css'>
        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/owl.carousel.min.css'>
        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/nice-select.css'>
        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/magnific-popup.css'>
        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/slicknav.min.css'>
        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/animate.css'>
        <!-- Main Stylesheets -->
    
        <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/influncers_assets/css/style.css'>
    
    
    
    
    
        <!--      from main static files-->
          <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/css/main.css'>
             <link rel="stylesheet" href='https://try-marketing.s3.amazonaws.com/static/home/css/try.scss'>
          <link href="https://try-marketing.s3.amazonaws.com/static/home/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="https://try-marketing.s3.amazonaws.com/static/home/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
      <link href="https://try-marketing.s3.amazonaws.com/static/home/vendor/aos/aos.css" rel="stylesheet">
      <link href="https://try-marketing.s3.amazonaws.com/static/home/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
      <link href="https://try-marketing.s3.amazonaws.com/static/home/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search