###前提・実現したいこと
bottle+nginx+uwsgiでwebアプリケーションを作成したいです。
既にnginxでkibanaを動かしており、それと同居させたいです。
###発生している問題・エラーメッセージ
--2017-03-05 17:42:33-- (試行: 3) http://localhost:8080/python localhost (localhost)|127.0.0.1|:8080 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... データが受信されませんでした 再試行しています。
###現在の設定等状況
- nginx
error_log /var/log/nginx/hoge.error.log warn; # basic authentification for kibana upstream kibana { server localhost:5601; } upstream python { #server unix:///run/uwsgi/app/hoge/socket/bottle.socket; server 127.0.0.1:8080; } server{ listen 80 default; server_name hoge.mydns.jp; error_log /var/log/nginx/nginx_hoge.error.log warn; access_log /var/log/nginx/nginx_hoge.access.log; location / { stub_status on; root /var/www/html/; index index.nginx-debian.html; } location /python/ { stub_status on; include /etc/nginx/uwsgi_params; uwsgi_pass python; } location ~ (/app/kibana|/bundles/|/status|/elasticsearch|/plugins|/timelion|/console) { stub_status on; auth_basic "Restricted"; auth_basic_user_file "/etc/nginx/.htpasswd"; proxy_pass http://kibana; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $http_host; } location ~ \.css { add_header Content-Type text/css; } location ~ \.js { add_header Content-Type application/x-javascript; } }
root@user:~/app# service nginx status ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since 日 2017-03-05 17:38:32 JST; 19min ago Process: 31373 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exit Process: 31383 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 31375 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS Main PID: 31385 (nginx) CGroup: /system.slice/nginx.service ├─31385 nginx: master process /usr/sbin/nginx -g daemon on; master_process on ├─31386 nginx: worker process └─31387 nginx: worker process 3月 05 17:38:32 user systemd[1]: Starting A high performance web server and a reverse proxy server... 3月 05 17:38:32 user systemd[1]: Started A high performance web server and a reverse proxy server.
- uwsgi
[uwsgi] master = true #plugin = python chdir = /var/www/python/python/ file = app.py #socket = /run/uwsgi/app/hoge/socket/bottle.socket socket = :8080 pidfile = /run/uwsgi/app/hoge/pid/bottle.pid chmod-socket = 666 uid = www-data gid = www-data buffer-size = 65535 #log log-x-forwarded-for = true log-format = %(addr) - %(user) [%(ltime)] "(method) %(uri) %(proto)" %(status) %(size)<code></code> "%(referer)" "%(uagent)" logto = /var/log/uwsgi/uwsgi.log
root@user:/etc/uwsgi/apps-available# uwsgi --ini myapp.ini [uWSGI] getting INI configuration from myapp.ini
*** Starting uWSGI 2.0.14 (32bit) on [Sun Mar 5 17:59:30 2017] *** compiled with version: 5.4.0 20160609 on 04 March 2017 14:06:55 os: Linux-4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:49:39 UTC 2017 nodename: user machine: i686 clock source: unix pcre jit disabled detected number of CPU cores: 2 current working directory: /etc/uwsgi/apps-available writing pidfile to /run/uwsgi/app/hoge/pid/bottle.pid detected binary path: /usr/local/bin/uwsgi setgid() to 33 setuid() to 33 chdir() to /var/www/python/python/ your processes number limit is 32041 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to TCP address :8080 fd 3 Python version: 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0x911c868 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 250854 bytes (244 KB) for 1 cores *** Operational MODE: single process *** WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x911c868 pid: 31711 (default app) *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 31711) spawned uWSGI worker 1 (pid: 31712, cores: 1)
- app.py
root@user:/var/www/python/python# pwd /var/www/python/python root@user:/var/www/python/python# cat app.py #!/usr/bin/env python # -*- coding:utf-8 -*- import logging import bottle @bottle.route('/python')# Handle HTTP GET for the application root def hello(): return bottle.template('<h1>Hello App Template</h1>\n') # Run bottle internal test server when invoked directly ie: non-uxsgi mode if __name__ == '__main__': bottle.run(host='localhost', port=8080, debug=True) # Run bottle in application mode. Required in order to get the application working with uWSGI! else: application = bottle.default_app()
- プロセス・ポート
root@user:~/app# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME metricbea 19367 root 5u IPv4 9090648 0t0 TCP localhost:34554->localhost:http (ESTABLISHED) nginx 31385 root 9u IPv4 8998095 0t0 TCP *:http (LISTEN) nginx 31386 www-data 9u IPv4 8998095 0t0 TCP *:http (LISTEN) nginx 31387 www-data 9u IPv4 8998095 0t0 TCP *:http (LISTEN) nginx 31387 www-data 10u IPv4 9090649 0t0 TCP localhost:http->localhost:34554 (ESTABLISHED) root@user:~/app# lsof -i:8080 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME uwsgi 31711 www-data 3u IPv4 9113003 0t0 TCP *:http-alt (LISTEN) uwsgi 31712 www-data 3u IPv4 9113003 0t0 TCP *:http-alt (LISTEN)
お手数をおかけして申し訳ありませんが、ご助力のほど、よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。