Nginx,Gunicorn在Ubuntu服务器上服务于Django应用启动问题

问题描述

我在HTTPS上看到Nginx欢迎屏幕,它正在运行,需要进一步的配置。并且http://devsmkapp.com可以正常工作。我是主持这种方式的新手(Digital Ocean,Gunicorn,Nginx),并且不确定从何处去。我已经配置了SSL证书和密钥,并且路径指向正确。我只是不确定如何获取它来加载Django应用和从http重定向。预先感谢任何人的帮助。

Nginx.conf

user www-data;
worker_processes auto;
pid /run/Nginx.pid;
include /etc/Nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        client_max_body_size 20M;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3,ref: POODLE
         ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/Nginx/access.log;
        error_log /var/log/Nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/x$

        ##
        # Virtual Host Configs
        ##

        include /etc/Nginx/conf.d/*.conf;
        include /etc/Nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.Nginx.org/ImapAuthenticateWithApachePHPScript
#
#       # auth_http localhost/auth.PHP;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIdplUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

认(/ etc / Nginx / sites-available / default)

# Default server configuration
#
server {
        listen 80;
        listen [::]:80 ipv6only=on default_server ;
        server_name _;

         return 301 https://$host$request_uri;
        keepalive_timeout 10;
}
server {
        # SSL configuration
        #
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;

        server_name devsmkapp.com www.devsmkapp.com;
         # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;
        keepalive_timeout 10;
        # Add index.PHP to the list if you are using PHP
        index index.html index.htm index.Nginx-debian.html;

        ssl on;
        server_name devsmkapp.com www.devsmkapp.com;
        ssl_certificate "/home/djangoadmin/server.crt";
        ssl_certificate_key "/home/djangoadmin/devsmkapp.com.key";

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers HIGH:!aNULL:!MD5;

        location / {
                # First attempt to serve request as file,then
                # as directory,then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        #location ~ \.PHP$ {
        #       include snippets/fastcgi-PHP.conf;
        #
        #       # With PHP-fpm (or other unix sockets):
        #       fastcgi_pass unix:/var/run/PHP/PHP7.0-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        #}

        # deny access to .htaccess files,if Apache's document root
        # concurs with Nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

独角兽通行证

ESCOD
● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enable
   Active: active (running) since Thu 2020-10-01 09:31:02 UTC; 14min ago
 Main PID: 15943 (gunicorn)
    Tasks: 4 (limit: 1152)
   CGroup: /system.slice/gunicorn.service
           ├─15943 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/ve
           ├─15965 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/ve
           ├─15968 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/ve
           └─15970 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/ve

Oct 01 09:31:02 ubuntu systemd[1]: Stopped gunicorn daemon.
Oct 01 09:31:02 ubuntu systemd[1]: Started gunicorn daemon.
Oct 01 09:31:03 ubuntu gunicorn[15943]: [2020-10-01 09:31:03 +0000] [15943] [INFO] Start
Oct 01 09:31:03 ubuntu gunicorn[15943]: [2020-10-01 09:31:03 +0000] [15943] [INFO] Liste
Oct 01 09:31:03 ubuntu gunicorn[15943]: [2020-10-01 09:31:03 +0000] [15943] [INFO] Using
Oct 01 09:31:03 ubuntu gunicorn[15943]: [2020-10-01 09:31:03 +0000] [15965] [INFO] Booti
Oct 01 09:31:03 ubuntu gunicorn[15943]: [2020-10-01 09:31:03 +0000] [15968] [INFO] Booti

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...