From e190825135b4f26b12d59b14352a18a78163b14f Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Sun, 3 May 2026 15:33:21 +0330 Subject: [PATCH] fix(nginx): remove api. subdomain and revert back to single domain for backend and fronted --- frontend/.env.sample | 2 +- nginx/nginx.conf | 69 +++++++------------------------------------- 2 files changed, 11 insertions(+), 60 deletions(-) diff --git a/frontend/.env.sample b/frontend/.env.sample index 5989de1..98d1bb8 100644 --- a/frontend/.env.sample +++ b/frontend/.env.sample @@ -1 +1 @@ -VITE_API_BASE_URL=https://api.qlockify.ir +VITE_API_BASE_URL=https://qlockify.ir diff --git a/nginx/nginx.conf b/nginx/nginx.conf index ef27af7..0a922b1 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -5,13 +5,6 @@ server { return 301 https://qlockify.ir$request_uri; } -server { - listen 80; - server_name api.qlockify.ir; - - return 301 https://api.qlockify.ir$request_uri; -} - server { listen 443 ssl; http2 on; @@ -42,58 +35,7 @@ server { client_max_body_size 100M; sendfile on; - location /api/ { - return 301 https://api.qlockify.ir$request_uri; - } - - location /admin/ { - return 301 https://api.qlockify.ir$request_uri; - } - - location /docs { - return 301 https://api.qlockify.ir$request_uri; - } - - location /redoc { - return 301 https://api.qlockify.ir$request_uri; - } - - location /openapi.json { - return 301 https://api.qlockify.ir$request_uri; - } - - location /static/ { - return 301 https://api.qlockify.ir$request_uri; - } - - location /media/ { - return 301 https://api.qlockify.ir$request_uri; - } - - location / { - proxy_pass http://frontend:80; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} - -server { - listen 443 ssl; - http2 on; - server_name api.qlockify.ir; - - ssl_certificate /etc/nginx/certs/fullchain.pem; - ssl_certificate_key /etc/nginx/certs/privkey.pem; - ssl_protocols TLSv1.2 TLSv1.3; - ssl_prefer_server_ciphers on; - ssl_session_timeout 1d; - ssl_session_cache shared:SSL:10m; - - client_max_body_size 100M; - sendfile on; - + # Static and Media files location /static/ { alias /usr/share/nginx/html/static/; expires 30d; @@ -106,6 +48,7 @@ server { access_log off; } + # Protect API Documentation with Basic Auth location ~ ^/(docs|redoc|openapi.json|api/docs|api/redoc|api/openapi.json|api/v1/docs) { auth_basic "Restricted API Documentation"; auth_basic_user_file /etc/nginx/.htpasswd; @@ -147,4 +90,12 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + + location / { + proxy_pass http://frontend:80; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } }