unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 691 forks source link

[strict-mode] unknown config directive: http-websockets #2360

Closed 00Asgaroth00 closed 2 years ago

00Asgaroth00 commented 2 years ago

Whle attempting to debug a web socket issue, I attempted to run uWSGI in strict mode to ensure that my settings were being recognized by uWSGI. It appears that strict mode does not recognize the configuration option http-websockets.

Looking at the documentation, it appears that the http-websockets option was introduces as part of version 1.9 and is built as part of uWSGI by default (Reference here)

Is this a known issue, or am I doing something wrong here. Any assistance would be appreciated.

Oct 22 09:47:10 servername uwsgi_emperor[686]: [uWSGI] getting INI configuration from dealer.ini
Oct 22 09:47:10 servername uwsgi_emperor[686]: [strict-mode] unknown config directive: http-websockets
Oct 22 09:47:10 servername uwsgi_emperor[686]: Fri Oct 22 09:47:10 2021 - [emperor] curse the uwsgi instance dealer.ini (pid: 14331)
Oct 22 09:47:10 servername uwsgi_emperor[686]: Fri Oct 22 09:47:10 2021 - [emperor] removed uwsgi instance dealer.ini

uWSGI emperor copnfiguration file:

[uwsgi]
plugin=syslog
logger = syslog:uwsgi_emperor
threaded-logger = true
socket_dir = /run/uwsgi
run_usr = uwsgi
run_gid = uwsgi

uid = %(run_usr)
gid = %(run_gid)
emperor = /etc/uwsgi.d
emperor-tyrant = true
cap = setgid,setuid
pcre-jit = true
thunder-lock = true
never-swap = true
enable-metrics = true

exec-asap = if [ ! -d %(socket_dir) ]; then umask 022; mkdir -p %(socket_dir); chmod 755 %(socket_dir); chown %(run_usr):%(run_gid) %(socket_dir); else if [ "$(stat -c '%%U' %(socket_dir))" != "%(run_usr)" ] || [ "$(stat -c '%%G' %(socket_dir))" != "%(run_gid)" ]; then chown %(run_usr):%(run_gid) %(socket_dir); fi fi

Vassal websocket application I'm trying to start in strict mode:

[uwsgi]
strict = true
plugins = syslog, python36, python36_gevent

master = true
master-fifo = /run/uwsgi/%n_master.fifo
procname = "[uwsgi:worker: %n]"
procname-master = "[uwsgi:master: %n]"
enable-metrics = true

disable-logging = false
logger = syslog:uwsgi_%n
threaded-logger = true
single-interpreter = true
chmod-socket = 666
socket = /run/uwsgi/%n.sock
env = APP_ENV=development
chdir = /data/apps/development/%n
home = /data/apps/development/%n/v-env
mount = /%n=wsgi.py
manage-script-name = true
vacuum = true

thunder-lock = true
harakiri = 300
buffer-size = 65535
post-buffering = 1    # buffer all of the http body > 1 byte
lazy-apps = true
stats = /run/uwsgi/%n_metrics.sock
memory-report = true
no-orphans = true
pcre-jit = true
never-swap = true

http-websockets
gevent = 100

nginx configuration

server {
  listen 443 ssl http2;
  server_name domain.example.com;
  include /etc/openresty/site_acl/domain.example.com.com.acl;
  root /var/empty/nginx;
  autoindex off;
  access_log syslog:server=unix:/dev/log,tag=nginx_example_com,nohostname time_combined;
  error_log  syslog:server=unix:/dev/log,tag=nginx_example_com,nohostname warn;
  add_header X-Frame-Options "DENY";
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";
  add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";

  ssl_certificate         /etc/openresty/site_ssl/domain.example.com.com.fullchain.crt;
  ssl_certificate_key     /etc/openresty/site_ssl/domain.example.com.com.key;
  ssl_trusted_certificate /etc/openresty/site_ssl/domain.example.com.com.chain.crt;
  ssl_stapling on;
  ssl_stapling_verify on;

  if ($host !~* ^(domain.example.com.com)$ ) {
    return 405;
  }

  location / {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;

    include /etc/openresty/conf/uwsgi_params;
    uwsgi_pass unix:///run/uwsgi/dealer.sock;
    # uwsgi_buffering off;
  }
}
xrmx commented 2 years ago

http-websockets is in the http plugin, check you have built that in or you have to load it. While you are at it add assign it to true

00Asgaroth00 commented 2 years ago

Excellent, thank you, that got rid of the error message in strict mode. I was under the impression that websockets was compiled into the core, seems like it is a plugin with this distributions package build.

Updated vassal configuration:

[uwsgi]
strict = true
plugins = syslog, http, python36, python36_gevent

master = true
master-fifo = /run/uwsgi/%n_master.fifo
procname = "[uwsgi:worker: %n]"
procname-master = "[uwsgi:master: %n]"
enable-metrics = true

disable-logging = false
logger = syslog:uwsgi_%n
threaded-logger = true
single-interpreter = true
chmod-socket = 666
socket = /run/uwsgi/%n.sock
env = APP_ENV=development
chdir = /data/apps/development/%n
home = /data/apps/development/%n/v-env
mount = /%n=wsgi.py
manage-script-name = true
vacuum = true

thunder-lock = true
harakiri = 300
buffer-size = 65535
post-buffering = 1    # buffer all of the http body > 1 byte
lazy-apps = true
stats = /run/uwsgi/%n_metrics.sock
memory-report = true
no-orphans = true
pcre-jit = true
never-swap = true

http-websockets = true
gevent = 100

Now I'm faced with the original issue I was trying to debug, it appears that the websoocket app is constantly returning a 404 for all requests it is being sent :(

Is there a way I can see what is being passed over the uwsgi socket to the application? What I mean is, how can I verify that the connection is indeed being upgraded to enable websocket type connections? Nginx configuration is above.

00Asgaroth00 commented 2 years ago

I'll close this ticket as the original issue was resolved.