Background
I am working on a docker-compose app made of 4 services: a django app, a wagtail django app, nginx, and postgresql. My main issue is with static files: they work fine with the development server, but not with nginx. The really strange part is that nginx shows that it is serving the static files, and they are accessible through their URL on a browser. How can I get them to show up?
From settings.py in wagtail app
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
STATICFILES_DIRS = [
os.path.join(PROJECT_DIR, 'static'),
''
]
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
From settings.py in django app
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
docker-compose.yml
version: '3.7'
services:
nginx:
image: nginx:latest
container_name: production_nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/error.log:/etc/nginx/error_log.log
#- /etc/letsencrypt/:/etc/letsencrypt/
- cms_static_volume:/usr/src/cms/static
- core_static_volume:/usr/src/core/static
ports:
- 80:80
- 443:443
depends_on:
- core
- cms
core:
build:
context: ./cirrus_core
dockerfile: Dockerfile.prod
command: gunicorn cirrus_core.wsgi:application --bind 0.0.0.0:8000
volumes:
- core_static_volume:/usr/src/core/static
expose:
- "8000"
env_file: .env
depends_on:
- db
cms:
build:
context: ./cirrus_cms
dockerfile: Dockerfile.prod
command: gunicorn cirrus_cms.wsgi:application --bind 0.0.0.0:8001
volumes:
- cms_static_volume:/usr/src/cms/static
expose:
- '8001'
env_file: .env
depends_on:
- db
db:
image: postgres:11.5-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file: .env.db
volumes:
postgres_data:
core_static_volume:
cms_static_volume:
nginx.conf
events{}
http {
upstream cms {
server cms:8001;
}
upstream core {
server core:8000;
}
server {
listen 80;
server_name dashboard.sentimentco.com 192.168.86.1;
location / {
proxy_pass http://cms/admin/login/?next=/admin/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /usr/src/cms/static/;
}
}
server {
listen 80;
server_name admin.sentimentco.com 192.168.86.1;
location / {
proxy_pass http://core/admin/login/?next=/admin/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /usr/src/core/static/;
}
}
}
nginx logs
77.247.108.110 - - [19/Aug/2019:20:56:51 +0000] "GET / HTTP/1.1" 400 37 "-" "-"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET / HTTP/1.1" 200 6387 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/modernizr-2.6.2.min.76e933e876d5.js HTTP/1.1" 200 10583 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/css/vendor/jquery-ui/jquery-ui-1.10.3.verdant.767104e7b415.css HTTP/1.1" 200 27112 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/css/core.a28f9631bc68.css HTTP/1.1" 200 78445 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/css/normalize.aa75c284e281.css HTTP/1.1" 200 2359 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/css/vendor/jquery.tagit.1060b2909c82.css HTTP/1.1" 200 832 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/css/layouts/login.ea7b231e7652.css HTTP/1.1" 200 1842 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/jquery.autosize.a300cc7b9e37.js HTTP/1.1" 200 5571 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/jquery-3.2.1.min.c9f5aeeca3ad.js HTTP/1.1" 200 86659 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/bootstrap-transition.7b8c2e460984.js HTTP/1.1" 200 2087 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/bootstrap-modal.b411788be2b6.js HTTP/1.1" 200 7031 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/jquery.datetimepicker.280df8b3286d.js HTTP/1.1" 200 108981 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/tag-it.a60812d95e27.js HTTP/1.1" 200 21758 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/bootstrap-tab.f9e4e160df7e.js HTTP/1.1" 200 3563 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/core.7690c99ae674.js HTTP/1.1" 200 17602 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor/jquery-ui-1.12.1.min.c15b1008dec3.js HTTP/1.1" 200 253669 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/wagtailadmin.8edb9675af94.js HTTP/1.1" 200 58279 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
192.168.86.1 - - [19/Aug/2019:20:56:59 +0000] "GET /static/wagtailadmin/js/vendor.a08a4452c3bc.js HTTP/1.1" 200 194518 "http://dashboard.sentimentco.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
result
django admin screenshot
Can anyone tell what's going on here?
It turns out I just needed to include mime.types in my nginx.conf. Big thanks to gasman for helping me figure out the problem.
Related
My nginx server (using django) is getting hit with thousands of these types of requests per second:
199.127.61.178 - - [09/Nov/2022:08:20:42 +0000] "GET http://www.wuqiaoxianzajituan.com/ HTTP/1.1" 500 186 "http://www.wuqiaoxianzajituan.com" "Mozilla/5.0 (Linux; U; Android 2.3.5; en-in; Micromax A87 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
104.238.222.87 - - [09/Nov/2022:08:20:42 +0000] "GET http://www.wuqiaoxianzajituan.com/ HTTP/1.1" 400 55440 "http://www.wuqiaoxianzajituan.com" "Mozilla/5.0 (Linux; Android 8.0.0; SM-G950F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36"
172.93.110.55 - - [09/Nov/2022:08:20:42 +0000] "GET http://tucgd.lixil-kitchen.cn/ HTTP/1.1" 400 55373 "http://tucgd.lixil-kitchen.cn" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/537.86.4"
104.243.37.94 - - [09/Nov/2022:08:20:42 +0000] "GET http://you.br-sx.com/ HTTP/1.1" 400 55205 "http://you.br-sx.com" "Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0 Mobile/15C114 Safari/604.1"
104.238.222.9 - - [09/Nov/2022:08:20:42 +0000] "GET https://skype.gmw.cn/?nf91C2a99VqP4D43fy6uPrgt0 HTTP/1.1" 400 55722 "https://skype.gmw.cn" "Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5"
104.238.205.70 - - [09/Nov/2022:08:20:42 +0000] "GET http://eqksp.drtjy.com/ HTTP/1.1" 400 55224 "http://eqksp.drtjy.com" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
103.195.103.32 - - [09/Nov/2022:08:20:42 +0000] "GET http://eqksp.drtjy.com/ HTTP/1.1" 400 55192 "http://eqksp.drtjy.com" "Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0"
104.243.37.94 - - [09/Nov/2022:08:20:42 +0000] "GET http://you.br-sx.com/ HTTP/1.1" 400 55133 "http://you.br-sx.com" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0"
173.208.239.195 - - [09/Nov/2022:08:20:42 +0000] "GET http://eqksp.drtjy.com/ HTTP/1.1" 500 588 "http://eqksp.drtjy.com" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36"
104.238.205.70 - - [09/Nov/2022:08:20:42 +0000] "GET http://you.br-sx.com/ HTTP/1.1" 400 55147 "http://you.br-sx.com" "Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0"
104.238.205.70 - - [09/Nov/2022:08:20:42 +0000] "GET https://skype.gmw.cn/?7n62R0Ocp5h8ymbM74co76w370m0Cv HTTP/1.1" 400 55741 "https://skype.gmw.cn" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"
104.238.222.9 - - [09/Nov/2022:08:20:42 +0000] "GET http://tucgd.lixil-kitchen.cn/ HTTP/1.1" 500 588 "http://tucgd.lixil-kitchen.cn" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"
104.238.222.88 - - [09/Nov/2022:08:20:42 +0000] "GET http://www.wuqiaoxianzajituan.com/ HTTP/1.1" 400 55372 "http://www.wuqiaoxianzajituan.com" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0"
103.195.103.32 - - [09/Nov/2022:08:20:42 +0000] "GET http://tucgd.lixil-kitchen.cn/ HTTP/1.1" 400 55366 "http://tucgd.lixil-kitchen.cn" "Mozilla/5.0 (iPad; CPU OS 10_3_3 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) CriOS/61.0.3163.73 Mobile/14G60 Safari/602.1"
104.238.222.88 - - [09/Nov/2022:08:20:42 +0000] "GET https://skype.gmw.cn/?DnV7mPJ19L1Li6bwt39aVP59oDDi6bJxPb8Pj0 HTTP/1.1" 400 55775 "https://skype.gmw.cn" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:59.0) Gecko/20100101 Firefox/59.0"
104.238.222.88 - - [09/Nov/2022:08:20:42 +0000] "GET https://skype.gmw.cn/?3as00v0ydeeRx5sXVa3wMoQ6 HTTP/1.1" 400 55676 "https://skype.gmw.cn" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
104.194.8.226 - - [09/Nov/2022:08:20:42 +0000] "GET http://you.br-sx.com/ HTTP/1.1" 400 55219 "http://you.br-sx.com" "Mozilla/5.0 (Linux; Android 6.0.1; SM-G532M Build/MMB29T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36"
104.238.222.88 - - [09/Nov/2022:08:20:42 +0000] "GET http://www.wuqiaoxianzajituan.com/ HTTP/1.1" 400 55434 "http://www.wuqiaoxianzajituan.com" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
104.243.37.94 - - [09/Nov/2022:08:20:42 +0000] "GET https://skype.gmw.cn/?I5RaB0sIBAt7W9i7iWueXU9104kJ HTTP/1.1" 400 55714 "https://skype.gmw.cn" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36"
104.194.8.226 - - [09/Nov/2022:08:20:42 +0000] "GET http://you.br-sx.com/ HTTP/1.1" 400 55238 "http://you.br-sx.com" "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14A456 Safari/602.1"
104.238.222.88 - - [09/Nov/2022:08:20:42 +0000] "GET http://px9i1.jntmzg.cn/ HTTP/1.1" 400 55245 "http://px9i1.jntmzg.cn" "Mozilla/5.0 (Linux; Android 8.0.0; FLA-LX3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.80 Mobile Safari/537.36"
...
199.127.60.99 - - [09/Nov/2022:13:19:50 +0000] "GET https://d518b.com/?s8023k1FRBDIvK6Rxw6q8h0e5S HTTP/1.1" 502 166 "https://d518b.com" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0/Nutch-1.12"
185.150.189.223 - - [09/Nov/2022:13:19:50 +0000] "GET https://d518b.com/?xCtRIk9u13N80G1J8xaWTF1GSLo80M6 HTTP/1.1" 502 568 "https://d518b.com" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"
104.238.221.227 - - [09/Nov/2022:13:19:50 +0000] "GET https://d518b.com/?25HwH49w9C9UqapejfQ3HQCX02EKbegWgvG4 HTTP/1.1" 502 166 "https://d518b.com" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"
104.243.34.218 - - [09/Nov/2022:13:19:50 +0000] "GET https://d518b.com/?v8iHIV5uWx4540GvN4apQ3dG3 HTTP/1.1" 502 166 "https://d518b.com" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0"
103.195.103.32 - - [09/Nov/2022:13:19:50 +0000] "GET https://d518b.com/?4FrrkvoMux8HR162L324b2 HTTP/1.1" 502 568 "https://d518b.com" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; InfoPath.1)"
199.127.63.156 - - [09/Nov/2022:13:19:50 +0000] "GET https://d518b.com/?A5cAxLa81Q52KCL752QK010X3NuQ HTTP/1.1" 502 568 "https://d518b.com" "Mozilla/5.0 (Linux; NetCast; U) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.31 SmartTV/7.5"
103.195.103.32 - - [09/Nov/2022:13:19:50 +0000] "GET https://d518b.com/?G2nga9Dw9q1Xy9bR7qBXB HTTP/1.1" 502 568 "https://d518b.com" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
They all seem to requests external URLs, (which I don't think my server needs to do for any legitimate reason), so I tried to deny them with my nginx config by denying matches to http, .com, cn, with this config:
upstream app_server {
server unix:/home/django/gunicorn.socket fail_timeout=0;
}
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
# Your Django project's media files - amend as required
location /media {
alias /home/django/django_project/django_project/media;
}
# your Django project's static files - amend as required
location /static {
alias /home/django/django_project/django_project/static;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python3/dist-packages/django/contrib/admin/static/admin/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://app_server;
limit_req zone=one;
limit_except GET HEAD POST {
deny all;
}
}
# ADDED THESE NEW LINES
location ~ http {
deny all;
}
location ~ .com {
deny all;
}
location ~ .cn {
deny all;
}
}
server {
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 4G;
server_name <MYURLHIDDEN>; # managed by Certbot
keepalive_timeout 5;
# Your Django project's media files - amend as required
location /media {
alias /home/django/django_project/django_project/media;
}
# your Django project's static files - amend as required
location /static {
alias /home/django/django_project/django_project/static;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python3/dist-packages/django/contrib/admin/static/admin/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://app_server;
limit_req zone=one;
limit_except GET HEAD POST {
deny all;
}
}
# ADDED THESE NEW LINES
location ~ http {
deny all;
}
location ~ .com {
deny all;
}
location ~ .cn {
deny all;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/<MYURLHIDDEN>/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/<MYURLHIDDEN>/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = <MYURLHIDDEN>) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name <MYURLHIDDEN>;
return 404; # managed by Certbot
}
But these types of requests are still hitting my access log, and my servers CPU keeps hitting 100% and site keeps going down. What am I doing wrong?
I have installed airflow2.1.1 on centos7 vm in our private network. Airflow webserver is built on flask. It uses flask web authentication.
I have configured airflow.cfg and webserver_config.py to use keycloak oauth2.
I am getting below error while logging in airflow web UI with keycloak for authentication
OAUTH code in webserver_config.py
from airflow.www_rbac.security import AirflowSecurityManager
from flask_appbuilder.security.manager import AUTH_OAUTH
import os
import json
AUTH_TYPE = AUTH_OAUTH
AUTH_USER_REGISTRATION = True
AUTH_USER_REGISTRATION_ROLE = "Admin"
# a mapping from the values of `userinfo["role_keys"]` to a list of FAB roles
AUTH_ROLES_MAPPING = {
"FAB_USERS": ["admin"],
"FAB_ADMINS": ["Admin"],
}
OAUTH_PROVIDERS = [
{'name':'keycloak', 'icon':'fa-user-circle', 'token_key':'access_token',
'remote_app': {
'client_id':'xxxxxx',
'client_secret':'xxxxxxxxxxxxxxxxxxx',
'api_base_url':'https://keycloak-1.dastc.stee.com:8443/auth/realms/sep',
'client_kwargs':{
'scope': 'email profile'
},
'request_token_url':None,
'access_token_url':'https://keycloak-1.dastc.stee.com:8443/auth/realms/sep/protocol/openid-connect/token',
'authorize_url':'https://keycloak-1.dastc.stee.com:8443/auth/realms/sep/protocol/openid-connect/auth'}
}
]
Error from airflow webserver
172.16.0.1 - - [26/Aug/2021:07:28:25 +0000] "GET / HTTP/1.1" 302 217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:25 +0000] "GET /home HTTP/1.1" 302 329 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:25 +0000] "GET /login/?next=https%3A%2F%2Fexp-3.dastc.stee.com%3A8090%2Fhome HTTP/1.1" 302 1001 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:25 +0000] "GET / HTTP/1.1" 302 217 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:25 +0000] "GET /home HTTP/1.1" 302 329 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:25 +0000] "GET /login/?next=https%3A%2F%2Fexp-3.dastc.stee.com%3A8090%2Fhome HTTP/1.1" 302 1001 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:43,501] {manager.py:1293} ERROR - OAUTH userinfo does not have username or email {}
172.16.0.1 - - [26/Aug/2021:07:28:43 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuZXh0IjpbImh0dHBzOi8vZXhwLTMuZGFzdGMuc3RlZS5jb206ODA5MC9ob21lIl19.gPk8CRlCWQtxpWemGEK575Q-0t_r488fczc1lDbVjsQ&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=5732a033-009f-4093-80d3-43321c5c646e.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 302 221 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:43 +0000] "GET /login/ HTTP/1.1" 302 871 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:43,734] {manager.py:1293} ERROR - OAUTH userinfo does not have username or email {}
172.16.0.1 - - [26/Aug/2021:07:28:43 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.SqKPp4eMJlY0wyPJxubLV-L78CpXKgpfm2ilTlgecSg&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=eec30213-f238-445a-b3f9-22db5091337d.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 302 221 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:43 +0000] "GET /login/ HTTP/1.1" 302 871 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:43,972] {manager.py:1293} ERROR - OAUTH userinfo does not have username or email {}
172.16.0.1 - - [26/Aug/2021:07:28:43 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.SqKPp4eMJlY0wyPJxubLV-L78CpXKgpfm2ilTlgecSg&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=384d3d06-dc9c-4478-bdea-917db0456d09.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 302 221 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /login/ HTTP/1.1" 302 871 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:44,190] {manager.py:1293} ERROR - OAUTH userinfo does not have username or email {}
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.SqKPp4eMJlY0wyPJxubLV-L78CpXKgpfm2ilTlgecSg&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=2561b99b-a098-4927-b8fe-5b4a4548b62f.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 302 221 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /login/ HTTP/1.1" 302 871 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:44,431] {manager.py:1293} ERROR - OAUTH userinfo does not have username or email {}
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.SqKPp4eMJlY0wyPJxubLV-L78CpXKgpfm2ilTlgecSg&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=a6486875-ce53-40d8-b9ed-461453a942e0.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 302 221 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /login/ HTTP/1.1" 302 871 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:44,677] {manager.py:1293} ERROR - OAUTH userinfo does not have username or email {}
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.SqKPp4eMJlY0wyPJxubLV-L78CpXKgpfm2ilTlgecSg&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=2710fb5a-f592-45d1-ade5-2dd7bbc3ca3e.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 302 221 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /login/ HTTP/1.1" 302 871 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:44,920] {manager.py:1293} ERROR - OAUTH userinfo does not have username or email {}
172.16.0.1 - - [26/Aug/2021:07:28:44 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.SqKPp4eMJlY0wyPJxubLV-L78CpXKgpfm2ilTlgecSg&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=1c7750d0-9517-4ba7-8c7c-6ff96fa4588a.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 302 221 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
[2021-08-26 07:28:46,128] {app.py:1892} ERROR - Exception on /oauth-authorized/keycloak [GET]
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/security/views.py", line 695, in oauth_authorized
resp = self.appbuilder.sm.oauth_remotes[provider].authorize_access_token()
File "/usr/local/lib/python3.6/site-packages/authlib/integrations/flask_client/remote_app.py", line 74, in authorize_access_token
params = self.retrieve_access_token_params(flask_req, request_token)
File "/usr/local/lib/python3.6/site-packages/authlib/integrations/base_client/base_app.py", line 145, in retrieve_access_token_params
params = self._retrieve_oauth2_access_token_params(request, params)
File "/usr/local/lib/python3.6/site-packages/authlib/integrations/base_client/base_app.py", line 126, in _retrieve_oauth2_access_token_params
raise MismatchingStateError()
authlib.integrations.base_client.errors.MismatchingStateError: mismatching_state: CSRF Warning! State not equal in request and response.
172.16.0.1 - - [26/Aug/2021:07:28:46 +0000] "GET /oauth-authorized/keycloak?state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.SqKPp4eMJlY0wyPJxubLV-L78CpXKgpfm2ilTlgecSg&session_state=c50b49a9-2878-4af6-8ce4-62da7b3a82fd&code=1c7750d0-9517-4ba7-8c7c-6ff96fa4588a.c50b49a9-2878-4af6-8ce4-62da7b3a82fd.5e50dd12-2de1-479c-906f-d5272f3ba911 HTTP/1.1" 500 2447 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
I'll be candid - I know very little about websockets, my config file was setup by a developer we had years ago, and even then I dont think his configuration was correct. All the HTTP(S) REST API responses work, but the websockets features are having issues.
I am getting an error from the web console in production, everything works on local:
WebSocket connection to 'wss://my.website.com/socket.io/?EIO=3&transport=websocket&sid=bE54hfVzKjRVT5H1AR1i' failed:
I have a little bit of a difficult environment where my socket.io server is running
In our AWS environment I have a Linux server running NGINX, because this sits behind a public facing AWS load balancer (public facing listens via 443 with SSL) sending traffic down through port 80 to the actual box, all the certificates are handled at the AWS load balancer rather than on box.
as a secondary issue, is there a reason my old developer would add keepalive 64 on a websocket server? the verbiage seems to be odd when websockets are supposed to stay up for long periods of time?
I know my issue has to be in the NGINX config, I dont suspect my issue is in my load balancer but I dont know where to start
from my local machine, I have tried to change the url in my config to ws:// and wss:// with no success
upstream my_nodejs_upstream {
server 127.0.0.1:8080;
keepalive 64;
}
server {
listen 80;
server_name my_nodejs_server;
root /home/www/application;
location / {
server_tokens off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_max_temp_file_size 0;
proxy_pass http://my_nodejs_upstream/;
proxy_redirect off;
proxy_read_timeout 240s;
}
}
Nodejs
const express = require('express')
const app = express()
const server = require('http').Server(app)
const io = require('socket.io')(server) // v2.0.4
io.on('connection', (socket) => {
// ...
})
// ...
app.use((req, res, next) => {
res.io = io
next()
})
app.use('/', require('./routes'))
const port = process.env.PORT
server.listen(port, () => {
// ...
})
client
const socket = io.connect(process.env.SOCKET_SERVER)
socket.on('connect', () => {
socket.emit('...', ...)
})
socket.on('...', data => {
// ...
})
access.log -> filtered for 400 errors
10.3.0.225 - - [29/Jul/2021:18:43:26 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=QNqTyFYHniVsHwRVATA- HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:26 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=eL9XCFhOpUc1x8v5ATA_ HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:26 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=sUeUwuQ0WZZ6srppATBB HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:26 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=RFmviPReFWc6jj0JATBA HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:26 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=h_-JSjypuJkd1VB9ATBC HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:26 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=aGtQf1Ei2YFt-mfZATBD HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:27 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=B3uR9cdYoZS28pJ2ATAh HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
10.3.0.45 - - [29/Jul/2021:18:43:27 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb0Yf&sid=ok8WIn_zywc-5LhOAS_a HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:27 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb0Yf.0&sid=EJYczgk3g6MkfXWRAS_b HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:29 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=jFE3Zhm59giR0_tYATBE HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:30 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=MK_Cxs3O2miJqc8EATBF HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=NhpayDE&sid=dweMe6kGyqK-Yt0qATAZ HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NhpayDE.0&sid=dweMe6kGyqK-Yt0qATAZ HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb2XP&sid=375bccUv_aKZr9saATAW HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb2XV&sid=cnTj1b2cB9G_SldMATAY HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb2XW&sid=8MEo84boodpm5OPyAS_n HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb2Xx&sid=7d0LBCT9jvM-Q9PoATAU HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb2Y3&sid=DpMuhNMh9jFvu7neATAV HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb2YF&sid=_Ndcj-_BAej_YUjNATAX HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "POST /socket.io/?EIO=3&transport=polling&t=Nhpb3Y7&sid=dweMe6kGyqK-Yt0qATAZ HTTP/1.1" 400 52 "https://my.ui-server.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=ULibUHaBWhNSu7hdATBK HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=KXUistz6s0Emu06kATBM HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=fuOE0YD01avGKg_gATBN HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=8T994wWah-1azLgoATBO HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:35 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=dReJzIK5lgkHblh4ATBP HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
10.3.0.225 - - [29/Jul/2021:18:43:36 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=eO_a9FJ0HWH_LSuDATBQ HTTP/1.1" 400 45 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"
I did not find anything meaningful inside the error.log
$ cat error.log
2021/07/29 06:08:01 [notice] 10145#10145: using inherited sockets from "6;"
I'm currently deploying the Django & React Web on the Elastic Beanstalk, but I still get the 500 error. Is there any method to get rid of this error? I use PostgreSQL, and I grepped only 500 errors down below.
Here's my git repository:
https://github.com/ujin43255252/davidgram
172.31.1.112 (14.231.228.185) - - [18/Jul/2018:12:02:48 +0000] "GET / HTTP/1.1" 500 527 "-" "-"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:12:17:10 +0000] "GET /admin HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:12:17:10 +0000] "GET /favicon.ico HTTP/1.1" 500 527 "http://davidgram.ap-northeast-2.elasticbeanstalk.com/admin" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:12:18:29 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:12:18:29 +0000] "GET /favicon.ico HTTP/1.1" 500 527 "http://davidgram.ap-northeast-2.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.29.137 (31.184.194.109) - - [18/Jul/2018:12:18:33 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
127.0.0.1 (-) - - [18/Jul/2018:12:25:07 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:12:25:08 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:12:25:09 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:12:25:10 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:12:25:57 +0000] "GET /robots.txt HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:12:26:00 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:12:26:00 +0000] "GET /favicon.ico HTTP/1.1" 500 527 "http://davidgram.ap-northeast-2.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.29.137 (85.69.223.3) - - [18/Jul/2018:12:30:18 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
172.31.29.137 (85.69.223.3) - - [18/Jul/2018:12:30:24 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
172.31.29.137 (203.189.153.192) - - [18/Jul/2018:12:38:27 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
172.31.29.137 (209.126.136.4) - - [18/Jul/2018:12:54:02 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
172.31.29.137 (164.177.41.204) - - [18/Jul/2018:12:54:15 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
172.31.1.112 (209.126.136.4) - - [18/Jul/2018:13:04:00 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:13:10:59 +0000] "GET /robots.txt HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.1.112 (143.248.234.146) - - [18/Jul/2018:13:10:59 +0000] "GET /favicon.ico HTTP/1.1" 500 527 "http://davidgram.ap-northeast-2.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.1.112 (177.189.145.3) - - [18/Jul/2018:13:14:41 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
172.31.29.137 (47.203.88.236) - - [18/Jul/2018:13:24:38 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28 (.NET CLR 3.5.30729)"
172.31.29.137 (31.184.194.109) - - [18/Jul/2018:13:37:56 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
172.31.29.137 (203.190.43.78) - - [18/Jul/2018:13:56:50 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
172.31.1.112 (179.55.191.177) - - [18/Jul/2018:14:38:19 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
172.31.1.112 (143.208.246.121) - - [18/Jul/2018:15:02:31 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
127.0.0.1 (-) - - [18/Jul/2018:15:19:05 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:15:19:07 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:15:19:08 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:15:19:09 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
172.31.29.137 (37.26.87.166) - - [18/Jul/2018:15:22:44 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
172.31.29.137 (70.51.79.246) - - [18/Jul/2018:15:34:30 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
172.31.29.137 (70.51.79.246) - - [18/Jul/2018:15:34:35 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
172.31.29.137 (103.255.74.132) - - [18/Jul/2018:15:34:52 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
172.31.29.137 (37.63.239.222) - - [18/Jul/2018:15:42:01 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
127.0.0.1 (-) - - [18/Jul/2018:15:44:02 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:15:44:04 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:15:44:05 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [18/Jul/2018:15:44:06 +0000] "GET / HTTP/1.1" 500 527 "-" "Python-urllib/2.7"
172.31.29.137 (143.248.234.146) - - [18/Jul/2018:15:44:26 +0000] "GET /robots.txt HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.29.137 (143.248.234.146) - - [18/Jul/2018:15:44:27 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.29.137 (143.248.234.146) - - [18/Jul/2018:15:44:28 +0000] "GET /favicon.ico HTTP/1.1" 500 527 "http://davidgram.ap-northeast-2.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.29.137 (143.248.234.146) - - [18/Jul/2018:15:44:29 +0000] "GET / HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
172.31.29.137 (143.248.234.146) - - [18/Jul/2018:15:44:29 +0000] "GET /favicon.ico HTTP/1.1" 500 527 "http://davidgram.ap-northeast-2.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
I suspect if this is one of your first deployments, that you simply have not added the Elastic Beanstalk hostname to ALLOWED_HOSTS in your settings.py.
But without the actual error logs, that is hard to be sure of. Using the Elastic Beanstalk console, you should be able to click "request logs" and then request the last 100 lines. One of the logfiles you will get from that is the error log, that has more detailed debugging information.
I have problem with setting https://github.com/lqez/django-summernote . I followed steps in configuration part and it works great with django runserver - I have summernote in admin page etc. But when I add it to public server, it loads just sometimes.
When I'm pressing F5 in admin page, I can see that sometimes summernote loads and sometimes it doesnt. In nginx-error.log I have this message, when it is not loaded:
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /admin/django_summernote/attachment/ HTTP/1.1" 200 3347 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
and I get something like:
Not Found
The requested URL /admin/django_summernote/attachment/ was not found on this server.
and this when it is loaded:
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/css/base.css HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/css/changelists.css HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/admin/RelatedObjectLookups.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/core.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/jquery.min.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/jquery.init.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/js/actions.min.js HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /admin/jsi18n/ HTTP/1.1" 200 2384 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
*ip* - - [20/Feb/2014:12:00:56 +0000] "GET /static/admin/img/icon_searchbox.png HTTP/1.1" 304 0 "http://domain.eu/admin/django_summernote/attachment/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"
I'm really confused, because it is properly installed and works well with django runserver. And when it is properly loaded, it works just fine. My static dir also has this files:
`-- django_summernote
|-- SOURCE
|-- django_summernote.css
|-- jquery.fileupload.js
|-- jquery.iframe-transport.js
|-- jquery.ui.widget.js
|-- lang
|-- summernote.css
`-- summernote.min.js
Thanks
It must be an debug mode when you're running django project with runserver.
If django runs in debug mode, serving static files via urls.py works fine. But this doesn't work as expected on debug=False.
You have to serve static files via web servers (like nginx) on production phase. Please refer https://docs.djangoproject.com/en/dev/howto/static-files/