From 980f563eb0d6edab96b814c4b272925fb92951ab Mon Sep 17 00:00:00 2001 From: Aidaho Date: Mon, 13 Oct 2025 10:24:03 +0300 Subject: [PATCH] v8.2.4: Add WebSocket support in Nginx configuration and update version - Introduced WebSocket support in Nginx models, templates, and JavaScript. - Updated database migration to version `8.2.4`. - Refactored logrotate configurations for consistency. - Added Page Size pragma in database initialization for optimized performance. --- app/modules/db/db_model.py | 3 ++- .../db/migrations/v8_2_4_update_version.py | 22 +++++++++++++++++++ app/modules/roxywi/class_models.py | 1 + .../nginx_section/templates/proxy_pass.j2 | 2 +- .../ansible/roles/nginx_section/vars/main.yml | 3 --- app/static/js/add_nginx.js | 5 +++++ app/static/js/edit_config.js | 3 +++ .../include/add_nginx/proxy_pass.html | 2 ++ config_other/logrotate/backup | 4 ++-- config_other/logrotate/roxy-wi | 8 +++---- 10 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 app/modules/db/migrations/v8_2_4_update_version.py diff --git a/app/modules/db/db_model.py b/app/modules/db/db_model.py index 2b9e4674..00a4bb95 100644 --- a/app/modules/db/db_model.py +++ b/app/modules/db/db_model.py @@ -36,7 +36,8 @@ def connect(get_migrator=None): conn = SqliteExtDatabase(db, pragmas=( ('cache_size', -1024 * 64), # 64MB page-cache. ('journal_mode', 'wal'), - ('foreign_keys', 1) + ('foreign_keys', 1), + ('page_size', 4096), )) migrator = SqliteMigrator(conn) if get_migrator: diff --git a/app/modules/db/migrations/v8_2_4_update_version.py b/app/modules/db/migrations/v8_2_4_update_version.py new file mode 100644 index 00000000..e97d8de0 --- /dev/null +++ b/app/modules/db/migrations/v8_2_4_update_version.py @@ -0,0 +1,22 @@ +from playhouse.migrate import * +from app.modules.db.db_model import connect, Version + +migrator = connect(get_migrator=1) + + +def up(): + """Apply the migration.""" + try: + Version.update(version='8.2.4').execute() + except Exception as e: + print(f"Error updating version: {str(e)}") + raise e + + +def down(): + """Roll back the migration.""" + try: + Version.update(version='8.2.3').execute() + except Exception as e: + print(f"Error rolling back migration: {str(e)}") + raise e diff --git a/app/modules/roxywi/class_models.py b/app/modules/roxywi/class_models.py index 32968ab3..9e128134 100644 --- a/app/modules/roxywi/class_models.py +++ b/app/modules/roxywi/class_models.py @@ -626,6 +626,7 @@ class NginxLocationRequest(BaseModel): proxy_send_timeout: Optional[int] = 60 headers: Optional[List[NginxHeaderRequest]] = None upstream: str + websocket: Optional[bool] = False @model_validator(mode='before') @classmethod diff --git a/app/scripts/ansible/roles/nginx_section/templates/proxy_pass.j2 b/app/scripts/ansible/roles/nginx_section/templates/proxy_pass.j2 index 76aaf747..15aaad55 100644 --- a/app/scripts/ansible/roles/nginx_section/templates/proxy_pass.j2 +++ b/app/scripts/ansible/roles/nginx_section/templates/proxy_pass.j2 @@ -79,7 +79,7 @@ location {{ location.location }} { proxy_read_timeout {{ location.proxy_read_timeout }}; proxy_send_timeout {{ location.proxy_send_timeout }}; - {% if nginx_proxy.websocket.enabled %} + {% if location.websocket %} # WebSocket proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; diff --git a/app/scripts/ansible/roles/nginx_section/vars/main.yml b/app/scripts/ansible/roles/nginx_section/vars/main.yml index ef00a98e..99f424c9 100644 --- a/app/scripts/ansible/roles/nginx_section/vars/main.yml +++ b/app/scripts/ansible/roles/nginx_section/vars/main.yml @@ -28,9 +28,6 @@ nginx_proxy: inactive: "60m" # Cache retention time for inactive entries levels: "1:2" # Directory structure levels - websocket: - enabled: false - # Custom error pages error_pages: enabled: false # Enable custom error pages diff --git a/app/static/js/add_nginx.js b/app/static/js/add_nginx.js index 345d3b0b..0c364c31 100644 --- a/app/static/js/add_nginx.js +++ b/app/static/js/add_nginx.js @@ -237,12 +237,17 @@ function getNginxFormData($form, form_name) { let header = {action, name, value}; headers.push(header); }); + let websocket = false; + if ($('input[name="websocket"]').is(':checked')) { + websocket = true; + } let location_config = { location, proxy_connect_timeout, proxy_read_timeout, proxy_send_timeout, headers, + websocket, upstream }; indexed_array['locations'].push(location_config) diff --git a/app/static/js/edit_config.js b/app/static/js/edit_config.js index 3866fa74..5626591f 100644 --- a/app/static/js/edit_config.js +++ b/app/static/js/edit_config.js @@ -798,6 +798,9 @@ function openNginxSection(section) { $('#proxy_read_timeout').val(location.proxy_read_timeout); $('#proxy_send_timeout').val(location.proxy_send_timeout); $('#proxy_pass-upstream').val(location.upstream); + if (location.websocket) { + $('#websocket').prop("checked", true); + } } if (data.compression) { $('#compression').prop("checked", true); diff --git a/app/templates/include/add_nginx/proxy_pass.html b/app/templates/include/add_nginx/proxy_pass.html index f0fa71f6..cf4fcac2 100644 --- a/app/templates/include/add_nginx/proxy_pass.html +++ b/app/templates/include/add_nginx/proxy_pass.html @@ -106,6 +106,8 @@ Timeouts: Timeouts (proxy_connect_timeout).
+ {{ checkbox('websocket', title=lang.words.enable|title() + ' Websocket', desc='Websocket') }} +
Upstream: {{ input('proxy_pass-upstream', name='upstream', placeholder='upstream_config') }}
{{lang.words.note|title()}}: {{lang.add_nginx_page.desc.def_backend}}, {{lang.add_nginx_page.desc.def_backend_exit}}. diff --git a/config_other/logrotate/backup b/config_other/logrotate/backup index 2f0b6a98..2e99361f 100644 --- a/config_other/logrotate/backup +++ b/config_other/logrotate/backup @@ -3,7 +3,7 @@ rotate 10 missingok notifempty - create 0644 apache apache - dateext + create 0644 apache apache + dateext sharedscripts } diff --git a/config_other/logrotate/roxy-wi b/config_other/logrotate/roxy-wi index b3a58201..56e2d675 100644 --- a/config_other/logrotate/roxy-wi +++ b/config_other/logrotate/roxy-wi @@ -3,8 +3,8 @@ rotate 10 missingok notifempty - create 0644 apache apache - dateext + create 0644 apache apache + dateext sharedscripts } @@ -13,7 +13,7 @@ rotate 10 missingok notifempty - create 0644 apache apache - dateext + create 0644 apache apache + dateext sharedscripts }