Sfoglia il codice sorgente

Switch frontend from host networking to bridge with configurable port

Host network mode caused port 80 to be unreachable on some networks
(e.g., routers blocking well-known ports). Switch to bridge networking
with Docker port mapping, which is more portable. Users can override
the frontend port via FRONTEND_PORT in .env (defaults to 80).

Also update nginx proxy_pass to use Docker DNS (backend:8080) instead
of 127.0.0.1:8080, since bridge mode containers have isolated networks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 16 ore fa
parent
commit
70c949c36f
3 ha cambiato i file con 10 aggiunte e 9 eliminazioni
  1. 4 0
      .env.example
  2. 2 5
      docker-compose.yml
  3. 4 4
      nginx.conf

+ 4 - 0
.env.example

@@ -1,3 +1,7 @@
+# Frontend port (default: 80)
+# Change this if port 80 is blocked or already in use on your network
+# FRONTEND_PORT=8000
+
 # MQTT Configuration
 # this configuration is needed to activat ethe integration with Home assistant
 # If you leave MQTT_BROKER empty, the integration will be skipped, and it won't affect the app in any way

+ 2 - 5
docker-compose.yml

@@ -5,11 +5,8 @@ services:
       dockerfile: Dockerfile
     image: ghcr.io/tuanchris/dune-weaver-frontend:main
     restart: always
-    cap_add:
-      - SYS_NICE  # Enable real-time thread priority for smooth UART communication
-    # ports:
-    #   - "8080:8080" # Map port 8080 of the container to 8080 of the host (access via http://localhost:8080)
-    network_mode: "host" # Use host network for device access
+    ports:
+      - "${FRONTEND_PORT:-80}:80"
     volumes:
       - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
     depends_on:

+ 4 - 4
nginx.conf

@@ -14,7 +14,7 @@ server {
 
     # API proxy to backend container
     location /api/ {
-        proxy_pass http://127.0.0.1:8080;
+        proxy_pass http://backend:8080;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -23,7 +23,7 @@ server {
 
     # WebSocket proxy
     location /ws/ {
-        proxy_pass http://127.0.0.1:8080;
+        proxy_pass http://backend:8080;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
@@ -35,7 +35,7 @@ server {
 
     # Static files from backend (pattern previews, custom logos)
     location /static/ {
-        proxy_pass http://127.0.0.1:8080;
+        proxy_pass http://backend:8080;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_cache_valid 200 1h;
@@ -43,7 +43,7 @@ server {
 
     # All backend API endpoints (legacy non-/api/ routes)
     location ~ ^/(list_theta_rho_files|preview_thr_batch|get_theta_rho_coordinates|upload_theta_rho|pause_execution|resume_execution|stop_execution|force_stop|soft_reset|skip_pattern|set_speed|get_speed|restart|shutdown|run_pattern|run_playlist|connect_device|disconnect_device|home_device|clear_sand|move_to_position|get_playlists|save_playlist|delete_playlist|rename_playlist|reorder_playlist|delete_theta_rho_file|get_status|list_serial_ports|serial_status|cache-progress|rebuild_cache|get_led_config|set_led_config|get_wled_ip|set_wled_ip|led|send_home|send_coordinate|move_to_center|move_to_perimeter|run_theta_rho|connect|disconnect|list_theta_rho_files_with_metadata|list_all_playlists|get_playlist|create_playlist|modify_playlist|add_to_playlist|preview_thr|preview|add_to_queue|restart_connection|controller_restart|recover_sensor_homing|run_theta_rho_file|download|check_software_update|update_software) {
-        proxy_pass http://127.0.0.1:8080;
+        proxy_pass http://backend:8080;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;