Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx配置oss #31

Open
cyberchao opened this issue Apr 22, 2019 · 1 comment
Open

nginx配置oss #31

cyberchao opened this issue Apr 22, 2019 · 1 comment

Comments

@cyberchao
Copy link

你好,我在本地测试没有问题,部署到阿里云上出现504,我怀疑是nginx找不到media了,但是如何把media路径修改成oss呢,这是我现在的配置:
`# the upstream component nginx needs to connect to
upstream django {
server unix://opt/uwsgitest/NewBlog/blog.sock; # for a file socket
# server 127.0.0.1:8001; # for a web port socket (we'll use this first)
# server oss-cn-shanghai.aliyuncs.com;
}

configuration of the server

server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name pandacoder.top; # substitute your machine's IP address or FQDN
charset utf-8;

# max upload size
client_max_body_size 75M;   # adjust to taste

# Django media
location /Blog_media  {
    proxy_pass http://pandacoderblog.oss-cn-shanghai.aliyuncs.com;
    #alias /opt/uwsgitest/media_root;  # your Django project's media files - amend as required
}

location /static {
    alias /opt/uwsgitest/NewBlog/static_root; # your Django project's static files - amend as required
}

# Finally, send all non-media requests to the Django server.
location / {
    uwsgi_pass  django;

proxy_pass http://pandacoderblog.oss-cn-shanghai.aliyuncs.com;

    include     /opt/uwsgitest/NewBlog/uwsgi_params; # the uwsgi_params file you installed
}

}
`

@cyberchao
Copy link
Author

# the upstream component nginx needs to connect to
upstream django {
    server unix://opt/uwsgitest/NewBlog/blog.sock; # for a file socket
    # server 127.0.0.1:8001; # for a web port socket (we'll use this first)
    # server oss-cn-shanghai.aliyuncs.com;
}

# configuration of the server
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve for
    server_name pandacoder.top; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /Blog_media  {
        proxy_pass http://pandacoderblog.oss-cn-shanghai.aliyuncs.com;
        #alias /opt/uwsgitest/media_root;  # your Django project's media files - amend as required
    }

    location /static {
        alias /opt/uwsgitest/NewBlog/static_root; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
#       proxy_pass http://pandacoderblog.oss-cn-shanghai.aliyuncs.com;
        include     /opt/uwsgitest/NewBlog/uwsgi_params; # the uwsgi_params file you installed
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant