Skip to content

Commit 8d4aec8

Browse files
authored
Merge pull request #589 from JAORMX/minimal-nginx
Add all-in-one minimal nginx config
2 parents 70fbc6e + bcb26ab commit 8d4aec8

File tree

2 files changed

+63
-17
lines changed

2 files changed

+63
-17
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ RUN chown -R codegate /var/lib/nginx && \
7878
chown -R codegate /var/log/nginx && \
7979
chown -R codegate /run
8080

81-
COPY nginx.conf /etc/nginx/conf.d/default.conf
81+
COPY nginx.conf /etc/nginx/nginx.conf
8282

8383
# Remove include /etc/nginx/sites-enabled/*; from the default nginx.conf
8484
# This way we don't introduce unnecessary configurations nor serve

nginx.conf

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,68 @@
1-
server {
2-
listen 9090;
1+
worker_processes 1;
2+
pid /run/nginx.pid;
3+
error_log /var/log/nginx/error.log;
4+
include /etc/nginx/modules-enabled/*.conf;
35

4-
server_name localhost;
6+
events {
7+
worker_connections 128;
8+
}
9+
10+
http {
11+
12+
##
13+
# Basic Settings
14+
##
15+
16+
sendfile on;
17+
tcp_nopush on;
18+
types_hash_max_size 2048;
19+
20+
##
21+
# Disable unnecessary features
22+
##
23+
24+
server_tokens off;
25+
autoindex off;
26+
27+
include /etc/nginx/mime.types;
28+
default_type application/octet-stream;
29+
30+
##
31+
# Logging Settings
32+
##
33+
34+
access_log off;
35+
error_log /var/log/nginx/error.log;
36+
37+
##
38+
# Gzip Settings
39+
##
40+
41+
gzip on;
42+
43+
server {
44+
listen 9090;
45+
46+
server_name localhost;
547

6-
root /var/www/html;
7-
index index.html;
48+
add_header X-Frame-Options SAMEORIGIN;
49+
add_header X-Content-Type-Options nosniff;
50+
add_header X-XSS-Protection "1; mode=block";
851

9-
location / {
10-
try_files $uri /index.html =404;
11-
}
52+
root /var/www/html;
53+
index index.html;
1254

13-
# Serve certificates from /app/codegate_volume/certs at /certificates
14-
location /certificates/codegate_ca.crt {
15-
alias /app/codegate_volume/certs/ca.crt;
16-
types { application/x-x509-ca-cert crt; }
17-
default_type application/x-x509-ca-cert;
18-
}
55+
location / {
56+
try_files $uri /index.html =404;
57+
expires 1h; # Cache files for 1 hour
58+
add_header Cache-Control "public, max-age=3600";
59+
}
1960

20-
error_log /var/log/nginx/error.log;
21-
access_log /var/log/nginx/access.log;
61+
# Serve certificates from /app/codegate_volume/certs at /certificates
62+
location /certificates/codegate_ca.crt {
63+
alias /app/codegate_volume/certs/ca.crt;
64+
types { application/x-x509-ca-cert crt; }
65+
default_type application/x-x509-ca-cert;
66+
}
67+
}
2268
}

0 commit comments

Comments
 (0)