diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..17f96b2 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +REACT_APP_PROD_NGINX_PORT=8081 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3d5c1cd..a177108 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,6 @@ COPY . . RUN npm run build FROM nginx:1.24.0-alpine AS production -COPY nginx.conf /etc/nginx/nginx.conf +COPY nginx.conf /etc/nginx/templates/default.conf.template COPY --from=builder /app/build /usr/share/nginx/html -EXPOSE 80 \ No newline at end of file +EXPOSE 8081 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 5333478..c24d939 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,7 +7,9 @@ services: context: . dockerfile: Dockerfile ports: - - 8000:80 + - 8081:8081 healthcheck: - test: ["CMD", "wget", "--no-verbose", "--tries=1", "http://127.0.0.1:80/healthz"] + test: ["CMD", "wget", "--no-verbose", "--tries=1", "http://127.0.0.1:8081/healthz"] restart: unless-stopped + environment: + - API_PORT=8080 diff --git a/nginx.conf b/nginx.conf index 1f03a7d..3941cc7 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,56 +1,60 @@ -events {} -http { - include mime.types; +server_tokens off; - server_tokens off; +gzip on; +gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - gzip on; - gzip_disable "MSIE [1-6]\.(?!.*SV1)"; +server { + listen 8081; + server_name localhost; + charset utf-8; + root /usr/share/nginx/html; + index index.html; + autoindex off; - server { - listen 80; - server_name localhost; - charset utf-8; - root /usr/share/nginx/html; - index index.html; - autoindex off; + set_real_ip_from 10.0.0.0/8; + set_real_ip_from 172.16.0.0/12; + set_real_ip_from 192.168.0.0/16; + real_ip_header X-Real-IP; - set_real_ip_from 10.0.0.0/8; - set_real_ip_from 172.16.0.0/12; - set_real_ip_from 192.168.0.0/16; - real_ip_header X-Real-IP; + location / { + try_files $uri $uri/ =404; + gzip_http_version 1.1; + gzip_vary on; + gzip_comp_level 6; + gzip_proxied any; + gzip_types + text/plain + text/css + text/js + text/javascript + text/x-js + text/xml + application/json + application/x-javascript + application/javascript + application/xml + application/xml+rss + image/svg+xml; + gzip_buffers 16 8k; + add_header Cache-Control public; + } - location / { - try_files $uri $uri/ =404; - gzip_http_version 1.1; - gzip_vary on; - gzip_comp_level 6; - gzip_proxied any; - gzip_types - text/plain - text/css - text/js - text/javascript - text/x-js - text/xml - application/json - application/x-javascript - application/javascript - application/xml - application/xml+rss - image/svg+xml; - gzip_buffers 16 8k; - add_header Cache-Control public; - } + location /api/ { + proxy_pass http://${API_ADDR}/api/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } - location = /healthz { - add_header 'Content-Type' 'text/plain'; - return 200 'Ok'; - } + location = /healthz { + add_header 'Content-Type' 'text/plain'; + return 200 'Ok'; + } - location = /favicon.ico { - access_log off; - log_not_found off; - } + location = /favicon.ico { + access_log off; + log_not_found off; } } \ No newline at end of file diff --git a/public/env.js b/public/env.js deleted file mode 100644 index 4358f68..0000000 --- a/public/env.js +++ /dev/null @@ -1,3 +0,0 @@ -window.env = { - API_PORT: '__API_PORT__', -}; \ No newline at end of file diff --git a/public/index.html b/public/index.html index f806942..258d28e 100644 --- a/public/index.html +++ b/public/index.html @@ -12,7 +12,6 @@