Skip to content

Commit 0553941

Browse files
committed
chore: add local testing nginx conf and clean up
1 parent d954f61 commit 0553941

File tree

6 files changed

+96
-116
lines changed

6 files changed

+96
-116
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ clean:
1414
docker volume rm ccn-coverage-vis_certs
1515
docker rmi $(docker images --filter=reference='ccn-coverage-vis*' -q)
1616

17+
.PHONY: build-test
18+
build-test:
19+
@echo "Create test docker container for $(VIS_DOCKER_IMAGE_NAME)"
20+
21+
docker build --build-arg NGINX_CONFIG="local-nginx.conf" -t $(VIS_DOCKER_IMAGE_NAME_PREFIX)/$(VIS_DOCKER_IMAGE_NAME) -f vis.dockerfile .
22+
1723
.PHONY: build
1824
build:
1925
@echo "Create docker container for $(VIS_DOCKER_IMAGE_NAME)"

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ We provide a docker compose environment for local testing. Run `docker compose u
8888
- Toggle Active
8989
- Better compatibility with local development
9090

91+
## Contributing
92+
Any contribution and pull requests are welcome! However, before you plan to implement some features or try to fix an uncertain issue, it is recommended to open a discussion first. You can also join our [Discord channel](https://discord.com/invite/gn4DKF83bP), or visit our [website](https://seattlecommunitynetwork.org/).
93+
94+
## License
95+
ccn-coverage-vis is released under Apache License. See [LICENSE](/LICENSE) for more details.

configs/local-nginx.conf

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# HTTP server - redirects to HTTPS
2+
server {
3+
listen 80;
4+
server_name localhost;
5+
6+
# Redirect all HTTP requests to HTTPS
7+
return 301 https://$host$request_uri;
8+
}
9+
10+
# HTTPS server
11+
server {
12+
listen 443 ssl;
13+
server_name localhost;
14+
15+
# SSL certificate configuration
16+
ssl_certificate /etc/nginx/ssl/certs/certificate.pem;
17+
ssl_certificate_key /etc/nginx/ssl/certs/private-key.pem;
18+
19+
# SSL protocols and ciphers for improved security
20+
ssl_protocols TLSv1.2 TLSv1.3;
21+
ssl_prefer_server_ciphers on;
22+
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
23+
ssl_session_timeout 1d;
24+
ssl_session_cache shared:SSL:50m;
25+
26+
# HSTS (HTTP Strict Transport Security)
27+
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
28+
29+
# Compression settings for better performance
30+
gzip on;
31+
gzip_vary on;
32+
gzip_min_length 10240;
33+
gzip_proxied expired no-cache no-store private auth;
34+
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript;
35+
gzip_disable "MSIE [1-6]\.";
36+
37+
# Root directory for the site
38+
root /usr/share/nginx/html;
39+
40+
# API and secure endpoints
41+
location ~ ^/(api|secure)/ {
42+
proxy_pass http://api:3000;
43+
proxy_http_version 1.1;
44+
proxy_set_header Upgrade $http_upgrade;
45+
proxy_set_header Connection 'upgrade';
46+
proxy_set_header Host $host;
47+
proxy_set_header X-Real-IP $remote_addr;
48+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
49+
proxy_set_header X-Forwarded-Proto $scheme;
50+
proxy_cache_bypass $http_upgrade;
51+
52+
# Timeout settings
53+
proxy_connect_timeout 60s;
54+
proxy_send_timeout 60s;
55+
proxy_read_timeout 60s;
56+
}
57+
58+
# Handle requests to /admin/assets/ - KEY FIX HERE
59+
location ^~ /admin/assets/ {
60+
# Rewrite requests from /admin/assets/ to /assets/
61+
rewrite ^/admin/assets/(.*) /assets/$1 last;
62+
}
63+
64+
# Static assets caching
65+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
66+
expires 1y;
67+
add_header Cache-Control "public, max-age=31536000, immutable";
68+
try_files $uri =404;
69+
}
70+
71+
# Handle all routes for the SPA
72+
location / {
73+
index index.html;
74+
try_files $uri $uri/ /index.html;
75+
}
76+
77+
# Error pages
78+
error_page 404 /index.html;
79+
error_page 500 502 503 504 /50x.html;
80+
location = /50x.html {
81+
try_files $uri =404;
82+
}
83+
}

configs/nginx.conf

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
1-
# HTTP server - redirects to HTTPS
21
server {
32
listen 80;
43
server_name localhost;
54

6-
# Redirect all HTTP requests to HTTPS
7-
return 301 https://$host$request_uri;
8-
}
9-
10-
# HTTPS server
11-
server {
12-
listen 443 ssl;
13-
server_name localhost;
14-
15-
# SSL certificate configuration
16-
ssl_certificate /etc/nginx/ssl/certs/certificate.pem;
17-
ssl_certificate_key /etc/nginx/ssl/certs/private-key.pem;
18-
19-
# SSL protocols and ciphers for improved security
20-
ssl_protocols TLSv1.2 TLSv1.3;
21-
ssl_prefer_server_ciphers on;
22-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
23-
ssl_session_timeout 1d;
24-
ssl_session_cache shared:SSL:50m;
25-
26-
# HSTS (HTTP Strict Transport Security)
27-
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
28-
295
# Compression settings for better performance
306
gzip on;
317
gzip_vary on;
@@ -37,25 +13,6 @@ server {
3713
# Root directory for the site
3814
root /usr/share/nginx/html;
3915

40-
# API and secure endpoints
41-
location ~ ^/(api|secure)/ {
42-
proxy_pass http://api:3000;
43-
proxy_http_version 1.1;
44-
proxy_set_header Upgrade $http_upgrade;
45-
proxy_set_header Connection 'upgrade';
46-
proxy_set_header Host $host;
47-
proxy_set_header X-Real-IP $remote_addr;
48-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
49-
proxy_set_header X-Forwarded-Proto $scheme;
50-
proxy_cache_bypass $http_upgrade;
51-
52-
# Timeout settings
53-
proxy_connect_timeout 60s;
54-
proxy_send_timeout 60s;
55-
proxy_read_timeout 60s;
56-
}
57-
58-
# Handle requests to /admin/assets/ - KEY FIX HERE
5916
location ^~ /admin/assets/ {
6017
# Rewrite requests from /admin/assets/ to /assets/
6118
rewrite ^/admin/assets/(.*) /assets/$1 last;

src/sites.json

Lines changed: 0 additions & 72 deletions
This file was deleted.

vis.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ COPY . .
1616
RUN npm run build && npm prune --production
1717

1818
FROM nginx:stable-alpine
19+
ARG NGINX_CONFIG="nginx.conf"
1920

2021
COPY --from=build /usr/src/app/build /usr/share/nginx/html
21-
COPY configs/nginx.conf /etc/nginx/conf.d/default.conf
22+
COPY configs/${NGINX_CONFIG} /etc/nginx/conf.d/default.conf
2223

2324
EXPOSE 443
2425

0 commit comments

Comments
 (0)