AWS EC2 服务器无法正确提供某些页面和静态文件

问题描述 投票:0回答:1

我刚刚从 github 克隆在 AWS EC2 上部署了一个网站。当我访问 Influencer MarketingCareer 页面时,服务器正确地提供来自 S3 Bucket 的静态文件。但是当我访问我的主页我们是谁页面时,它不提供静态文件,我也没有获取这些页面内容(原始数据)。我认为它不提供静态文件是可以的,但是两个页面的内容都消失了。我在这里缺少什么。我是 AWS 和网站部署的新手,所以如果我犯了任何错误,请现在告诉我,我会纠正它。如果您需要任何其他信息,我会添加它。

配置 Nginx 代理传递给 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;
    }
}

存储桶策略、跨域资源共享(CORS)和用户策略

{
    "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 会议文件

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
python django amazon-web-services amazon-s3 django-staticfiles
1个回答
0
投票

我什至没有在您的主页上看到请求的图像。这表明您的 HTML 源代码存在问题(浏览器无法正确解释它)。我建议您修复 W3 验证器发现的问题https://validator.w3.org/nu/?doc=http%3A%2F%2F3.17.142.65%2F 看看是否有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.