Error 503 in OpenShift server - django

That's my first Django project and I'm trying to deploy it to OpenShift, but I have a problem: when I'm trying to open app's page, I see "503: Service Temporarily Unavailable" message. I thought that app wasn't started so I tried to launch 'ctl_app start' in ssh and I've got this:
python: can't open file 'app.py': [Errno 2] No such file or directory
I tried to start app this way: rhc app start customerquiz and got this:
RESULT:
customerquiz started
But it took no effect. Well, I tried to look the state of app:
$ rhc app show --state customerquiz
Cartridge python-2.7, mysql-5.1, phpmyadmin-3.4 is started
And that's what in server logs:
$ rhc tail customerquiz
==> mysql-5.1/log/mysql_error.log <==
130519 17:32:54 [Note] /usr/libexec/mysqld: Shutdown complete
130519 17:32:54 mysqld_safe mysqld from pid file /var/lib/openshift/000005//mysql-5.1/pid/mysql.pid ended
130519 17:33:04 mysqld_safe Starting mysqld daemon with databases from /var/lib/openshift/000005//mysql-5.1/data/
130519 17:33:04 InnoDB: Initializing buffer pool, size = 16.0M
130519 17:33:05 InnoDB: Completed initialization of buffer pool
130519 17:33:05 InnoDB: Started; log sequence number 0 44233
130519 17:33:05 [Note] Event Scheduler: Loaded 0 events
130519 17:33:05 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.69' socket: '/var/lib/openshift/000005//mysql-5.1/socket/mysql.sock' port: 3306 Source distribution
==> python-2.7/logs/appserver.log <==
python: can't open file 'app.py': [Errno 2] No such file or directory
==> phpmyadmin-3.4/logs/access_log-20130519-000000-EST <==
109.254.107.11 - - [19/May/2013:17:14:13 -0400] "GET /phpmyadmin/themes/pmahomme/img/error.ico HTTP/1.1" 200 5430 "https://customerquiz-unclelem.rhcloud.com/phpmyadmin/phpmyadmin.css.php?server=1&token=436aa&js_frame=right&nocache=5471357898" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
- - - [19/May/2013:17:14:13 -0400] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.15 (Red Hat) (internal dummy connection)"
109.254.107.11 - admin [19/May/2013:17:14:18 -0400] "GET /phpmyadmin/ HTTP/1.1" 200 2580 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
109.254.107.11 - admin [19/May/2013:17:14:19 -0400] "GET /phpmyadmin/main.php?token=436aa HTTP/1.1" 200 35472 "https://customerquiz-unclelem.rhcloud.com/phpmyadmin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
109.254.107.11 - adminB [19/May/2013:17:14:21 -0400] "GET /phpmyadmin/version_check.php?&_nocache=1368998062197204658 HTTP/1.1" 200 44 "https://customerquiz-unclelem.rhcloud.com/phpmyadmin/main.php?token=436aa" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
109.254.107.11 - admin [19/May/2013:17:14:19 -0400] "GET /phpmyadmin/navigation.php?token=436aa HTTP/1.1" 200 5029 "https://customerquiz-unclelem.rhcloud.com/phpmyadmin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
109.254.107.11 - admin [19/May/2013:17:20:49 -0400] "GET /phpmyadmin/ HTTP/1.1" 200 2580 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
109.254.107.11 - admin [19/May/2013:17:20:50 -0400] "GET /phpmyadmin/navigation.php?token=436aa HTTP/1.1" 200 5029 "https://customerquiz-unclelem.rhcloud.com/phpmyadmin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
109.254.107.11 - admin [19/May/2013:17:20:50 -0400] "GET /phpmyadmin/main.php?token=436aa HTTP/1.1" 200 35472 "https://customerquiz-unclelem.rhcloud.com/phpmyadmin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
109.254.107.11 - admin [19/May/2013:17:20:52 -0400] "GET /phpmyadmin/version_check.php?&_nocache=1368998453881950766 HTTP/1.1" 200 44 "https://customerquiz-unclelem.rhcloud.com/phpmyadmin/main.php?token=8436aa" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0"
==> phpmyadmin-3.4/logs/error_log-20130519-000000-EST <==
[Sun May 19 17:12:56 2013] [notice] Digest: done
[Sun May 19 17:12:56 2013] [notice] Apache/2.2.15 (Unix) PHP/5.3.3 configured -- resuming normal operations
[Sun May 19 17:28:00 2013] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:openshift_t:s0:c6,c356
[Sun May 19 17:28:00 2013] [notice] Digest: generating secret for digest authentication ...
[Sun May 19 17:28:00 2013] [notice] Digest: done
[
Sun May 19 17:28:00 2013] [notice] Apache/2.2.15 (Unix) PHP/5.3.3 configured -- resuming normal operations
[Sun May 19 17:33:17 2013] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:openshift_t:s0:c6,c356
[Sun May 19 17:33:17 2013] [notice] Digest: generating secret for digest authentication ...
[Sun May 19 17:33:17 2013] [notice] Digest: done
[Sun May 19 17:33:17 2013] [notice] Apache/2.2.15 (Unix) PHP/5.3.3 configured -- resuming normal operations
Does anyone have any ideas what can be wrong?
P.S. That's deployed project source code, if you need it: https://github.com/uncleLem/CustomerQuiz (I just changed database connection parameters).
P.P.S. Oh, BTW, if I open https://customerquiz-unclelem.rhcloud.com/phpmyadmin/ directly, I can see phpMyAdmin page.

We are not using mod_wsgi with these new carts. 2.7 uses gevent and 3.3 uses WebOb
Take a look at how we set up the app.py in the 2.7 cart
https://github.com/openshift/openshift-community-cartridge-python-2.7/blob/master/template/app.py
and for 3.3
https://github.com/openshift/openshift-community-cartridge-python-3.3/blob/master/template/app.py
Can you review the following blog post to see if it helps?
https://www.openshift.com/blogs/host-python-in-a-community-cart

Related

not found(deploying via digitalocean, nginx, ubuntu, Gunicorn )

I tried to deploy Django via digitalocean, nginx, ubuntu, and Gunicorn.
I followed the tutorial that digitaloccean provided.
Everything was fine before the step of binding it with Gunicorn.
I was able to use the run "manage.py runserver 0.0.0.0:8000"and was able to see the website on port 8000 of the IP address;
however when I tried to run gunicorn --bind 0.0.0.0:8000 biostar.wsgi
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$ gunicorn --bind 0.0.0.0:8000 biostar.wsgi
[2021-06-23 12:55:36 +0000] [134047] [INFO] Starting gunicorn 20.1.0
[2021-06-23 12:55:36 +0000] [134047] [INFO] Listening at: http://0.0.0.0:8000 (134047)
[2021-06-23 12:55:36 +0000] [134047] [INFO] Using worker: sync
[2021-06-23 12:55:36 +0000] [134049] [INFO] Booting worker with pid: 134049
,and tried to connect to the IP address again, the 404 not found error occurred.output
But when I tried to run sudo gunicorn --bind 0.0.0.0:8000 biostar.wsgi
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$ sudo gunicorn --bind 0.0.0.0:8000 biostar.wsgi
[2021-06-23 12:54:09 +0000] [134021] [INFO] Starting gunicorn 20.0.4
[2021-06-23 12:54:09 +0000] [134021] [INFO] Listening at: http://0.0.0.0:8000 (134021)
[2021-06-23 12:54:09 +0000] [134021] [INFO] Using worker: sync
[2021-06-23 12:54:09 +0000] [134023] [INFO] Booting worker with pid: 134023
celery error No module named 'django'
[2021-06-23 12:54:09 +0000] [134023] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 383, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/corey/digitalocceancrew/digitalcrew/biostar/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
[2021-06-23 12:54:09 +0000] [134023] [INFO] Worker exiting (pid: 134023)
[2021-06-23 12:54:09 +0000] [134021] [INFO] Shutting down: Master
[2021-06-23 12:54:09 +0000] [134021] [INFO] Reason: Worker failed to boot.
I also tried every port of the IP address but none of them worked.
This is the output of systemctl status gunicorn.service
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-06-19 09:14:20 UTC; 4 days ago
TriggeredBy: ● gunicorn.socket
Main PID: 34545 (gunicorn)
Tasks: 4 (limit: 1136)
Memory: 111.6M
CGroup: /system.slice/gunicorn.service
├─34545 /home/corey/digitalocceancrew/virtualcrew/bin/python /home/corey/digitalocceancrew/virtualcrew/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock biostar.wsgi:application
├─34557 /home/corey/digitalocceancrew/virtualcrew/bin/python /home/corey/digitalocceancrew/virtualcrew/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock biostar.wsgi:application
├─34558 /home/corey/digitalocceancrew/virtualcrew/bin/python /home/corey/digitalocceancrew/virtualcrew/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock biostar.wsgi:application
└─34559 /home/corey/digitalocceancrew/virtualcrew/bin/python /home/corey/digitalocceancrew/virtualcrew/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock biostar.wsgi:application
Jun 23 11:59:20 crew gunicorn[34557]: WARNING 2021-06-23 07:59:20,623 log.log_response 224 Not Found: /.env
Jun 23 11:59:20 crew gunicorn[34557]: - - [23/Jun/2021:07:59:20 -0400] "GET /.env HTTP/1.0" 404 179 "-" "python-requests/2.25.1"
Jun 23 12:06:31 crew gunicorn[34558]: WARNING 2021-06-23 08:06:31,852 log.log_response 224 Not Found: /
Jun 23 12:06:31 crew gunicorn[34558]: - - [23/Jun/2021:08:06:31 -0400] "GET / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
Jun 23 12:24:40 crew gunicorn[34557]: WARNING 2021-06-23 08:24:40,352 log.log_response 224 Not Found: /.env
Jun 23 12:24:40 crew gunicorn[34557]: - - [23/Jun/2021:08:24:40 -0400] "GET /.env HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 23 12:24:40 crew gunicorn[34558]: WARNING 2021-06-23 08:24:40,553 log.log_response 224 Not Found: /
Jun 23 12:24:40 crew gunicorn[34558]: - - [23/Jun/2021:08:24:40 -0400] "POST / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 23 12:24:54 crew gunicorn[34559]: WARNING 2021-06-23 08:24:54,081 log.log_response 224 Not Found: /
Jun 23 12:24:54 crew gunicorn[34559]: - - [23/Jun/2021:08:24:54 -0400] "GET / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
And this is the output of sudo journalctl -u gunicorn
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$ sudo journalctl -u gunicorn
-- Logs begin at Sun 2021-06-20 07:46:26 UTC, end at Wed 2021-06-23 12:51:37 UTC. --
Jun 20 07:46:26 crew gunicorn[34559]: WARNING 2021-06-20 03:46:26,682 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS1wZGZfMjEudHh0.xml
Jun 20 07:46:26 crew gunicorn[34559]: - - [20/Jun/2021:03:46:26 -0400] "GET /MTI4LjE5OS45Mi45MS1wZGZfMjEudHh0.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 07:46:51 crew gunicorn[34557]: WARNING 2021-06-20 03:46:51,386 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS0xMDUtcGRmLnR4dA==.xml
Jun 20 07:46:51 crew gunicorn[34557]: - - [20/Jun/2021:03:46:51 -0400] "GET /MTI4LjE5OS45Mi45MS0xMDUtcGRmLnR4dA==.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 09:04:48 crew gunicorn[34559]: WARNING 2021-06-20 05:04:48,093 log.log_response 224 Not Found: /.env
Jun 20 09:04:48 crew gunicorn[34559]: - - [20/Jun/2021:05:04:48 -0400] "GET /.env HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 20 09:04:48 crew gunicorn[34557]: WARNING 2021-06-20 05:04:48,585 log.log_response 224 Not Found: /
Jun 20 09:04:48 crew gunicorn[34557]: - - [20/Jun/2021:05:04:48 -0400] "POST / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 20 09:24:00 crew gunicorn[34558]: WARNING 2021-06-20 05:24:00,154 log.log_response 224 Not Found: /_ignition/execute-solution
Jun 20 09:24:00 crew gunicorn[34558]: - - [20/Jun/2021:05:24:00 -0400] "GET /_ignition/execute-solution HTTP/1.0" 404 179 "-" "python-requests/2.18.4"
Jun 20 09:47:12 crew gunicorn[34557]: WARNING 2021-06-20 05:47:12,781 log.log_response 224 Not Found: /
Jun 20 09:47:12 crew gunicorn[34557]: - - [20/Jun/2021:05:47:12 -0400] "GET / HTTP/1.0" 404 179 "-" "-"
Jun 20 09:47:13 crew gunicorn[34559]: WARNING 2021-06-20 05:47:13,166 log.log_response 224 Not Found: /
Jun 20 09:47:13 crew gunicorn[34559]: - - [20/Jun/2021:05:47:13 -0400] "GET / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; CensysInspect/1.1; +https://about.censys.io/)"
Jun 20 09:58:11 crew gunicorn[34558]: WARNING 2021-06-20 05:58:11,030 log.log_response 224 Not Found: /.env
Jun 20 09:58:11 crew gunicorn[34558]: - - [20/Jun/2021:05:58:11 -0400] "GET /.env HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 20 09:58:11 crew gunicorn[34557]: WARNING 2021-06-20 05:58:11,217 log.log_response 224 Not Found: /
Jun 20 09:58:11 crew gunicorn[34557]: - - [20/Jun/2021:05:58:11 -0400] "POST / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 20 10:11:55 crew gunicorn[34559]: WARNING 2021-06-20 06:11:55,505 log.log_response 224 Not Found: /
Jun 20 10:11:55 crew gunicorn[34559]: - - [20/Jun/2021:06:11:55 -0400] "GET / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/>
Jun 20 10:40:41 crew gunicorn[34557]: WARNING 2021-06-20 06:40:41,937 log.log_response 224 Not Found: /.env
Jun 20 10:40:41 crew gunicorn[34557]: - - [20/Jun/2021:06:40:41 -0400] "GET /.env HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 20 10:40:42 crew gunicorn[34558]: WARNING 2021-06-20 06:40:42,935 log.log_response 224 Not Found: /
Jun 20 10:40:42 crew gunicorn[34558]: - - [20/Jun/2021:06:40:42 -0400] "POST / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
Jun 20 11:38:28 crew gunicorn[34558]: WARNING 2021-06-20 07:38:28,734 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS0zOC1wZGYudHh0.xml
Jun 20 11:38:28 crew gunicorn[34558]: - - [20/Jun/2021:07:38:28 -0400] "GET /MTI4LjE5OS45Mi45MS0zOC1wZGYudHh0.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 11:43:16 crew gunicorn[34559]: WARNING 2021-06-20 07:43:16,900 log.log_response 224 Not Found: /robots.txt
Jun 20 11:43:16 crew gunicorn[34559]: - - [20/Jun/2021:07:43:16 -0400] "GET /robots.txt HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
Jun 20 11:43:17 crew gunicorn[34557]: WARNING 2021-06-20 07:43:17,763 log.log_response 224 Not Found: /
Jun 20 11:43:17 crew gunicorn[34557]: - - [20/Jun/2021:07:43:17 -0400] "GET / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
Jun 20 11:46:49 crew gunicorn[34559]: WARNING 2021-06-20 07:46:49,299 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS0zODFhbWNvOWkudHh0.xml
Jun 20 11:46:49 crew gunicorn[34559]: - - [20/Jun/2021:07:46:49 -0400] "GET /MTI4LjE5OS45Mi45MS0zODFhbWNvOWkudHh0.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 11:47:02 crew gunicorn[34557]: WARNING 2021-06-20 07:47:02,987 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS03Zmh0c2VsODUudHh0.xml
Jun 20 11:47:02 crew gunicorn[34557]: - - [20/Jun/2021:07:47:02 -0400] "GET /MTI4LjE5OS45Mi45MS03Zmh0c2VsODUudHh0.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 11:52:56 crew gunicorn[34558]: WARNING 2021-06-20 07:52:56,575 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS16c3FiMG12ZmMudHh0.xml
Jun 20 11:52:56 crew gunicorn[34558]: - - [20/Jun/2021:07:52:56 -0400] "GET /MTI4LjE5OS45Mi45MS16c3FiMG12ZmMudHh0.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 11:53:48 crew gunicorn[34558]: WARNING 2021-06-20 07:53:48,748 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS1wZGZfMTM5LnR4dA==.xml
Jun 20 11:53:48 crew gunicorn[34558]: - - [20/Jun/2021:07:53:48 -0400] "GET /MTI4LjE5OS45Mi45MS1wZGZfMTM5LnR4dA==.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 11:56:02 crew gunicorn[34559]: WARNING 2021-06-20 07:56:02,167 log.log_response 224 Not Found: /boaform/admin/formLogin
Jun 20 11:56:02 crew gunicorn[34559]: - - [20/Jun/2021:07:56:02 -0400] "POST /boaform/admin/formLogin HTTP/1.0" 404 179 "http://128.199.92.91:80/admin/login.asp" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Geck>
Jun 20 12:04:31 crew gunicorn[34558]: WARNING 2021-06-20 08:04:31,453 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS1wZGZfMTM4LnR4dA==.xml
Jun 20 12:04:31 crew gunicorn[34558]: - - [20/Jun/2021:08:04:31 -0400] "GET /MTI4LjE5OS45Mi45MS1wZGZfMTM4LnR4dA==.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 12:05:44 crew gunicorn[34557]: WARNING 2021-06-20 08:05:44,775 log.log_response 224 Not Found: /mathematical_ideas_12th_edition_online_free.pdf
Jun 20 12:05:44 crew gunicorn[34557]: - - [20/Jun/2021:08:05:44 -0400] "GET /mathematical_ideas_12th_edition_online_free.pdf HTTP/1.0" 404 179 "-" "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKi>
Jun 20 12:13:36 crew gunicorn[34559]: WARNING 2021-06-20 08:13:36,178 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS1kcXQ2Mm52YXMudHh0.xml
Jun 20 12:13:36 crew gunicorn[34559]: - - [20/Jun/2021:08:13:36 -0400] "GET /MTI4LjE5OS45Mi45MS1kcXQ2Mm52YXMudHh0.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 12:15:09 crew gunicorn[34559]: WARNING 2021-06-20 08:15:09,785 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS1wZGZfMTc3LnR4dA==.xml
Jun 20 12:15:09 crew gunicorn[34559]: - - [20/Jun/2021:08:15:09 -0400] "GET /MTI4LjE5OS45Mi45MS1wZGZfMTc3LnR4dA==.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 12:17:00 crew gunicorn[34559]: WARNING 2021-06-20 08:17:00,000 log.log_response 224 Not Found: /
Jun 20 12:17:00 crew gunicorn[34559]: - - [20/Jun/2021:08:16:59 -0400] "GET / HTTP/1.0" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36"
Jun 20 12:22:12 crew gunicorn[34559]: WARNING 2021-06-20 08:22:12,841 log.log_response 224 Not Found: /MTI4LjE5OS45Mi45MS1jcnUweW5kdjEudHh0.xml
Jun 20 12:22:12 crew gunicorn[34559]: - - [20/Jun/2021:08:22:12 -0400] "GET /MTI4LjE5OS45Mi45MS1jcnUweW5kdjEudHh0.xml HTTP/1.0" 404 179 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
Jun 20 12:27:35 crew gunicorn[34557]: WARNING 2021-06-20 08:27:35,621 log.log_response 224 Not Found: /
This is the output of ls -l /run/gunicorn.sock and netstat -tlpn | grep 'gunicorn'(The second one does not have any output)
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$ sudo ls -l /run/gunicorn.sock
srw-rw-rw- 1 root root 0 Jun 19 09:03 /run/gunicorn.sock
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$ sudo netstat -tlpn | grep 'gunicorn'
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$
When I type in sudo tail -f /var/log/nginx/error.log, it started running and stuck.(no output)
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$ sudo tail -f /var/log/nginx/error.log
Output of sudo netstat -tulpn
(virtualcrew) corey#crew:~/digitalocceancrew/digitalcrew$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 90046/nginx: master
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 559/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1163/sshd: /usr/sbi
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 4284/postgres
tcp6 0 0 :::80 :::* LISTEN 90046/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1163/sshd: /usr/sbi
udp 0 0 127.0.0.53:53 0.0.0.0:* 559/systemd-resolve
I have the following questions:
What might possibly cause this error?
Does being able to run it on local server means that the error is not caused by the source code?
What can I try to fix this issue?
Thank you !!!

kubernetes ingress websockets (socket.io)

I keep getting bad requests (400) when trying to open a websocket, and I'm trying to figure out why. The back-end is built on flask with flask-socketio. Here is my Docker container for the back-end:
FROM alpine:edge
RUN apk update
RUN apk add python3 py3-cffi py3-bcrypt libc-dev py3-psycopg2 py3-gevent
RUN pip3 install --upgrade pip
RUN pip3 install flask flask-restful flask-jwt-extended gunicorn requests flask-sqlalchemy flask-socketio
ADD ./rest-api /root/rest-api
ADD ./ui/dist/ui /root/ui
CMD ["gunicorn", "-k", "gevent", "-w", "1", "--bind", "0.0.0.0:3001", "--access-logfile", "-", "--chdir", "/root/rest-api/", "app:app"]
Here are my yaml files:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: my-global-ip
networking.gke.io/managed-certificates: my-certificate
nginx.ingress.kubernetes.io/add-base-url: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/websocket-services: "my-service-web"
nginx.ingress.kubernetes.io/proxy-send-timeout: "1800"
nginx.ingress.kubernetes.io/proxy-read-timeout: "1800"
spec:
rules:
- http:
paths:
- path: /grafana/*
backend:
serviceName: my-service-web
servicePort: grafana-port
- path: /*
backend:
serviceName: my-service-web
servicePort: web-app-port
apiVersion: v1
kind: Service
metadata:
name: my-service-web
spec:
ports:
- port: 3000
name: grafana-port
targetPort: grafana-port
protocol: TCP
- port: 3001
name: web-app-port
targetPort: web-app-port
protocol: TCP
selector:
app: my-cloud
type: NodePort
I can see from the logs that the requests reach the back-end container:
10.166.0.42 - - [26/Nov/2019:08:52:22 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.4.2.1 - - [26/Nov/2019:08:52:23 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.4.2.1 - - [26/Nov/2019:08:52:25 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.4.2.1 - - [26/Nov/2019:08:52:28 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.4.2.1 - - [26/Nov/2019:08:52:34 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.166.0.41 - - [26/Nov/2019:08:52:39 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.166.0.41 - - [26/Nov/2019:08:52:44 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.166.0.42 - - [26/Nov/2019:08:52:49 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
10.4.2.1 - - [26/Nov/2019:08:52:54 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
What I can't figure out is how to configure kubernetes ingress to follow flask-socketio configuration for nginx:
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5000/socket.io;
}
How do I do the connection upgrade to websocket in kubernetes ingress?
Update:
I instantiated SocketIO with logs enabled and got the following:
6f3a03945f174b039b033e887079b97d: Sending packet OPEN data {'sid': '6f3a03945f174b039b033e887079b97d', 'upgrades': [], 'pingTimeout': 60000, 'pingInterval': 25000}
6f3a03945f174b039b033e887079b97d: Sending packet MESSAGE data 0
6f3a03945f174b039b033e887079b97d: Received request to upgrade to websocket
10.166.0.43 - - [26/Nov/2019:10:19:45 +0000] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0
I almost had it right from the beginning. I changed the CMD in my Dockerfile to (as per Flask-socketio docs):
gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 module:app
Here's the complete Dockerfile:
FROM alpine:edge
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update && apk upgrade
RUN apk add python3 py3-cffi py3-bcrypt libc-dev py3-psycopg2 py3-gevent-websocket
RUN pip3 install --upgrade pip
RUN pip3 install flask flask-restful flask-jwt-extended gunicorn requests flask-sqlalchemy flask-socketio
ADD ./rest-api /root/rest-api
ADD ./ui/dist/ui /root/ui
CMD ["gunicorn", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "-w", "1", "--bind", "0.0.0.0:3001", "--timeout", "180", "--access-logfile", "-", "--chdir", "/root/rest-api/", "app:app"]

regex fail2ban rules

I am setting up Fail2ban on my server, recently got a lots bad bots is crawling my site cause my SQL server down
From my Apache2 logs
51.255.65.13 - - [10/Dec/2017:12:03:19 +0800] "GET /crew/nm0935095-gary-winick HTTP/1.0" 200 17985 "-" "Mozilla/5.0 (compatible; AhrefsBot/5.2; +http://ahrefs.com/robot/)"
51.255.65.30 - - [10/Dec/2017:12:03:31 +0800] "GET /movie/tt0498567-summer-time-machine-blues HTTP/1.0" 200 17658 "-" "Mozilla/5.0 (compatible; AhrefsBot/5.2; +http://ahrefs.com/robot/)"
217.182.132.190 - - [10/Dec/2017:12:03:36 +0800] "GET /movie/tt1705064-genji-monogatari:-sennen-no-nazo/ HTTP/1.0" 200 17344 "-" "Mozilla/5.0 (compatible; AhrefsBot/5.2; +http://ahrefs.com/robot/)"
how to create a failregex for "ahrefs.com" ?
Many Thanks
In order to catch anything containing "ahrefs.com", your failregex would look as follows:
failregex = ^<HOST>.*ahrefs\.com.*
Where the <HOST> tag is built-in Fail2ban as an alias for (?:::f{4,6}:)?(?P<host>\S+):
https://www.fail2ban.org/wiki/index.php/Apache

apache2 not showing flask app on local server

I was following this tutorial:
https://pythonprogramming.net/creating-first-flask-web-app/?completed=/flask-web-development-introduction/
On my local server (home machine on local network).
Flask itself starts properly
>>> python /var/www/FlaskApp/FlaskApp/__init__.py
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [31/Oct/2016 22:56:29] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [31/Oct/2016 22:56:29] "GET /favicon.ico HTTP/1.1" 404 -
flask starts
But Apache is showing its default webpage no matter what.
sudo a2enmod wsgi
Module wsgi already enabled
cat /var/www/FlaskApp/FlaskApp/init.py
from flask import Flask
app = Flask(__name__)
#app.route('/')
def homepage():
return "Hi There, how you're doin?"
if __name__ == "__main__":
app.run()(debug=True)
cat /etc/apache2/sites-available/FlaskApp.conf
<VirtualHost *>
ServerName dagzserv
ServerAdmin my#email.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Require all granted
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite FlaskApp
Site FlaskApp already enabled
I have tried adding app.run(host='0.0.0.0', port=5000)
I do have /etc/hosts dagserv as my ip in localnetwork (10.0.1.xxx)
Also tried ServerName as localhost.
One thing i did not understood is how exactly Apache is finding that "FlaskApp.conf" but i assumed that it is scanning its config directory
(/etc/apache2/sites-available/FlaskApp.conf)
I am getting no errors in /var/logs/apache2
cat access.log
10.0.1.14 - - [31/Oct/2016:22:46:52 -0700] "GET / HTTP/1.1" 200 3524 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"
10.0.1.14 - - [31/Oct/2016:22:49:14 -0700] "GET / HTTP/1.1" 200 3524 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"
10.0.1.14 - - [31/Oct/2016:22:49:15 -0700] "GET / HTTP/1.1" 200 3523 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"
10.0.1.101 - - [31/Oct/2016:22:56:18 -0700] "GET /favicon.ico HTTP/1.1" 404 499 "-" "Mozilla/5.0 (X11; Ubuntu; Linux armv7l; rv:49.0) Gecko/20100101 Firefox/49.0"
cat error.log
[Mon Oct 31 22:45:47.288264 2016] [wsgi:warn] [pid 982] mod_wsgi: Compiled for Python/2.7.11.
[Mon Oct 31 22:45:47.288623 2016] [wsgi:warn] [pid 982] mod_wsgi: Runtime using Python/2.7.12.
[Mon Oct 31 22:45:47.314433 2016] [mpm_prefork:notice] [pid 982] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Mon Oct 31 22:45:47.314616 2016] [core:notice] [pid 982] AH00094: Command line: '/usr/sbin/apache2'
[Mon Oct 31 22:48:52.171206 2016] [mpm_prefork:notice] [pid 982] AH00169: caught SIGTERM, shutting down
[Mon Oct 31 22:48:53.766824 2016] [wsgi:warn] [pid 2360] mod_wsgi: Compiled for Python/2.7.11.
[Mon Oct 31 22:48:53.766940 2016] [wsgi:warn] [pid 2360] mod_wsgi: Runtime using Python/2.7.12.
[Mon Oct 31 22:48:53.775947 2016] [mpm_prefork:notice] [pid 2360] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Mon Oct 31 22:48:53.776083 2016] [core:notice] [pid 2360] AH00094: Command line: '/usr/sbin/apache2'
1. How Apache is finding that "FlaskApp.conf"
There one line in /etc/apache2/apache2.conf to include virtual host configurations:
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
Apache2 server will load apache2.conf and also include the virtual host configurations.
2. Why Apache is showing its default webpage no matter what.
If you access the server via IP address, Apache will return based on its default site configuration in /etc/sites-available/000-default.conf. So if you want to access your WSGI server via IP address, you should disable the Apache default site configuration first:
sudo a2dissite 000-default.conf
service apache2 restart

Authenticating error while signing in to EMM agent App

I have successfully got the credentials on my mail id for enrolling my device through WSO2 EMM. But when i am signing in using the mail credentials its giving an error which "Enrollment failed -Please contact administrator "
The logs were:
Chrome/44.0.2403.133 Mobile Safari/537.36"
172.17.29.121 - - [16/Jun/2016:12:34:53 +0530] "GET /emm-web-agent/public/asset-download-agent-android/asset/android-agent.apk HTTP/1.1" 200 2896941 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)"
172.17.29.121 - - [16/Jun/2016:12:35:32 +0530] "GET /emm-web-agent/public/asset-download-agent-android/asset/android-agent.apk HTTP/1.1" 200 590411 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)"
172.17.29.121 - - [16/Jun/2016:12:40:13 +0530] "GET /emm-web-agent/public/asset-download-agent-android/asset/android-agent.apk HTTP/1.1" 200 590411 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)
172.17.29.121 - - [16/Jun/2016:12:42:45 +0530] "POST /dynamic-client-web/register HTTP/1.1" 201 148 "-" "Mozilla/5.0 ( compatible ), Android"
172.17.29.121 - - [16/Jun/2016:12:42:45 +0530] "POST /oauth2/token HTTP/1.1" 200 160 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
172.17.29.121 - - [16/Jun/2016:12:42:45 +0530] "GET /mdm-android-agent/device/license HTTP/1.1" 401 23 "-" "Mozilla/5.0 ( compatible ), Android"
According to the conversation the problem is with the permission you have provided to the given user role.
You can use an existing role with device management permission as sashika has suggested.
There is a login permission as the very last permission entry in the permission management UI, please include that permission to the related role in order to overcome the situation.
You need to add permissions to the role - specifically the "enroll" role.