Назад | Перейти на главную страницу

Настройка субдомена для указания на приложение фляги в той же цифровой капле океана (с uwsgi и nginx в Ubuntu 15.10)

У меня есть домен abc.com, который указывает на статическую html-страницу в /var/www/abc.com/public_html.

Я хочу разместить приложение Flask на одной и той же капле (может быть, на другом порту?), Которое доступно через поддомен demo.abc.com.

Я следовал инструкциям Вот, и Вот, но мне кажется, что они сейчас не работают.

Вот как сейчас выглядит мой файл зоны

$ORIGIN abc.com.
$TTL 1800
abc.com. IN SOA ns1.digitalocean.com. hostmaster.abc.com. 1451918078 10800 3600 604800 1800
abc.com. 1800 IN NS ns1.digitalocean.com.
abc.com. 1800 IN NS ns2.digitalocean.com.
abc.com. 1800 IN NS ns3.digitalocean.com.
abc.com. 1800 IN A 111.222.333.44
*.abc.com. 1800 IN CNAME abc.com.

Я создал app.py в /var/www/demo.abc.com/, в котором

from flask import Flask
application = Flask(__name__)

@application.route("/")
def hello():
    return 'Hello World!'

if __name__ == "__main__":
    application.run(host='0.0.0.0')

У меня есть 3 файла в / etc / nginx / sites-available -

дефолт

abc.com

demo.abc.com

из которых только abc.com и demo.abc.com символически связаны с /etc/nginx/sites-enabled

Вот как выглядит demo.abc.com:

server {
    listen 80;
    server_tokens off;
    server_name demo.abc.com;

     location / {
         include uwsgi_params;
         uwsgi_pass unix:/tmp/demo.sock;
     }

     location /static {
         alias /var/www/demo.abc.com/static;
     }

     ## Only requests to our Host are allowed
     if ($host !~ ^(demo.abc.com.com|www.demo.abc.com)$ ) {
        return 444;
     }
}

Вот как выглядит abc.com:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/abc.com/public_html;

        server_name abc.com;

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

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
        }
}

Вот по умолчанию:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name _;

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

Вот как выглядит /etc/uwsgi/apps-available/demo.abc.com.ini

[uwsgi]
vhost = true
socket = /tmp/demo.sock
venv = /var/www/demo.abc.com/.env
chdir = /var/www/demo.abc.com
module = app
callable = application

master = true
processes = 5

chmod-socket = 660
vacuum = true

die-on-term = true

abc.com работает нормально, а demo.abc.com не работает. Я не получаю никаких ошибок при запуске служб nginx и uwsgi. Однако я новичок в них обоих. Пожалуйста, объясни мне, что я делаю неправильно.

РЕДАКТИРОВАТЬ

Прикрепление полной журнал uwsgi, и nginx access.log (Второй - 88 МБ). Я не уверен, как получить только части журнала неудачных запросов. Насколько я понимаю, они выглядят так -

uwsgi.log

Sun Jan 17 07:54:58 2016 - *** Starting uWSGI 2.0.7-debian (64bit) on [Sun Jan 17 07:54:58 2016] ***
Sun Jan 17 07:54:58 2016 - compiled with version: 5.2.1 20150903 on 08 September 2015 19:33:31
Sun Jan 17 07:54:58 2016 - os: Linux-4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015
Sun Jan 17 07:54:58 2016 - nodename: Poolka.com
Sun Jan 17 07:54:58 2016 - machine: x86_64
Sun Jan 17 07:54:58 2016 - clock source: unix
Sun Jan 17 07:54:58 2016 - pcre jit disabled
Sun Jan 17 07:54:58 2016 - detected number of CPU cores: 1
Sun Jan 17 07:54:58 2016 - current working directory: /
Sun Jan 17 07:54:58 2016 - writing pidfile to /run/uwsgi/app/demo.poolka.com/pid
Sun Jan 17 07:54:58 2016 - detected binary path: /usr/bin/uwsgi-core
Sun Jan 17 07:54:58 2016 - setgid() to 33
Sun Jan 17 07:54:58 2016 - setuid() to 33
Sun Jan 17 07:54:58 2016 - your processes number limit is 1833
Sun Jan 17 07:54:58 2016 - your memory page size is 4096 bytes
Sun Jan 17 07:54:58 2016 - detected max file descriptor number: 1024
Sun Jan 17 07:54:58 2016 - VirtualHosting mode enabled.
Sun Jan 17 07:54:58 2016 - lock engine: pthread robust mutexes
Sun Jan 17 07:54:58 2016 - thunder lock: disabled (you can enable it with --thunder-lock)
Sun Jan 17 07:54:58 2016 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/demo.poolka.com/socket fd 3
Sun Jan 17 07:54:58 2016 - uwsgi socket 1 bound to UNIX address /tmp/demo.sock fd 5
Sun Jan 17 07:54:58 2016 - Python version: 2.7.10 (default, Oct 14 2015, 16:09:02)  [GCC 5.2.1 20151010]
Sun Jan 17 07:54:58 2016 - Set PythonHome to /var/www/demo.poolka.com/.env
Sun Jan 17 07:54:58 2016 - *** Python threads support is disabled. You can enable it with --enable-threads ***
Sun Jan 17 07:54:58 2016 - Python main interpreter initialized at 0x1f08d00
Sun Jan 17 07:54:58 2016 - your server socket listen backlog is limited to 100 connections
Sun Jan 17 07:54:58 2016 - your mercy for graceful operations on workers is 60 seconds
Sun Jan 17 07:54:58 2016 - mapped 436608 bytes (426 KB) for 5 cores
Sun Jan 17 07:54:58 2016 - *** Operational MODE: preforking ***
Sun Jan 17 07:54:58 2016 - WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1f08d00 pid: 17624 (default app)
Sun Jan 17 07:54:58 2016 - *** uWSGI is running in multiple interpreter mode ***
Sun Jan 17 07:54:58 2016 - spawned uWSGI master process (pid: 17624)
Sun Jan 17 07:54:58 2016 - spawned uWSGI worker 1 (pid: 17632, cores: 1)
Sun Jan 17 07:54:58 2016 - spawned uWSGI worker 2 (pid: 17633, cores: 1)
Sun Jan 17 07:54:58 2016 - spawned uWSGI worker 3 (pid: 17634, cores: 1)
Sun Jan 17 07:54:58 2016 - spawned uWSGI worker 4 (pid: 17635, cores: 1)
Sun Jan 17 07:54:58 2016 - spawned uWSGI worker 5 (pid: 17636, cores: 1)

access.log

14.183.60.220 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=37008&ts=1426138782918&m=20&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
86.129.146.109 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=6006&ts=1427056285299&m=30&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
86.129.146.109 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=48005&ts=1397342348934&m=30&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
14.183.60.220 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=28006&ts=1409495783294&m=20&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
14.183.60.220 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=20008&ts=1426240752454&m=20&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
31.18.246.156 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=6008&ts=1427052397699&m=10&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
31.18.246.156 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=41008&ts=1423783986283&m=10&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
31.18.246.156 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=23008&ts=1427067411049&m=10&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
14.183.60.220 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=37009&ts=1426108634237&m=20&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
14.183.60.220 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=46001&ts=1409495784000&m=20&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
14.183.60.220 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=20009&ts=1426224478835&m=20&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
14.183.60.220 - - [17/Jan/2016:13:38:52 -0500] "GET /items?c=11001&ts=1426240749118&m=20&T= HTTP/1.1" 404 177 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"