Skip to content

Commit 46e47b0

Browse files
committed
switch from lighttp to nginx for the homepage
1 parent abe36f0 commit 46e47b0

File tree

5 files changed

+109
-25
lines changed

5 files changed

+109
-25
lines changed

homepage/Dockerfile

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
FROM alpine:3.17
1+
FROM nginxinc/nginx-unprivileged:alpine3.21-perl
2+
LABEL maintainer "Mike Smith <mike.smith@embl.de>"
3+
ENV TZ="Europe/Berlin"
24

3-
RUN apk update \
4-
&& apk add lighttpd bash \
5-
&& rm -rf /var/cache/apk/*
5+
COPY nginx.conf /etc/nginx/conf.d/default.conf
66

7-
COPY lighttpd.conf /etc/lighttpd/lighttpd.conf
8-
9-
RUN mkdir -p /var/www/localhost/htdocs /var/shared
10-
WORKDIR /var/www/localhost/htdocs
7+
WORKDIR /var/www/html
118

9+
ADD images/favicon.tar.gz ./
1210
COPY images images/
13-
RUN tar xzvf images/favicon.tar.gz
1411

1512
COPY css css/
16-
1713
COPY html/* ./
1814

15+
USER root
1916
## This is just a symlink.
2017
## The actual file is created on a shared PVC by the git updater job
2118
RUN ln -s /var/shared/sitemap.txt sitemap.txt
2219
RUN ln -s /var/shared/robots.txt robots.txt
20+
USER nginx
2321

24-
RUN touch /run/lighttpd.pid && chown -R 100:100 /run/lighttpd.pid
25-
26-
USER lighttpd
27-
28-
CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
22+
EXPOSE 8080

homepage/html/about.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ <h4>Why we collect data</h4>
129129
<span class="text-muted"></span>
130130
</div>
131131
</footer>
132-
<script
133-
src="https://code.jquery.com/jquery-3.7.0.slim.min.js"
134-
integrity="sha256-tG5mcZUtJsZvyKAxYLVXrmjKBVLd6VpVccqz/r4ypFE="
135-
crossorigin="anonymous"></script>
132+
<script src="https://code.jquery.com/jquery-3.7.0.slim.min.js" integrity="sha256-tG5mcZUtJsZvyKAxYLVXrmjKBVLd6VpVccqz/r4ypFE=" crossorigin="anonymous"></script>
136133
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
137134
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
138135
</body>

homepage/html/index.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ <h1 class="card-title">Code Search</h1>
110110
<span class="text-muted"></span>
111111
</div>
112112
</footer>
113-
<script
114-
src="https://code.jquery.com/jquery-3.7.0.slim.min.js"
115-
integrity="sha256-tG5mcZUtJsZvyKAxYLVXrmjKBVLd6VpVccqz/r4ypFE="
116-
crossorigin="anonymous"></script>
113+
<script src="https://code.jquery.com/jquery-3.7.0.slim.min.js" integrity="sha256-tG5mcZUtJsZvyKAxYLVXrmjKBVLd6VpVccqz/r4ypFE=" crossorigin="anonymous"></script>
117114
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
118115
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
119116
</body>

homepage/nginx.conf

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
geo $blocked_ips {
2+
104.206.97.90 1; # add as many single IPs
3+
default 0; # everybody else
4+
}
5+
6+
server {
7+
listen 8080 default;
8+
9+
root /var/www/html;
10+
access_log /var/log/nginx/access_home.log;
11+
error_log /var/log/nginx/error_home.log;
12+
set $fpm_backend 127.0.0.1;
13+
14+
location / {
15+
index index.html;
16+
}
17+
18+
# Basic configuration
19+
expires off;
20+
server_tokens off;
21+
client_max_body_size 4m;
22+
keepalive_timeout 20s;
23+
sendfile on;
24+
tcp_nopush on;
25+
26+
# Forwarding EMBL ingress IP addresses to the access logs
27+
set_real_ip_from 10.133.0.0/16;
28+
real_ip_header X-Forwarded-For;
29+
real_ip_recursive on;
30+
31+
# Security
32+
add_header X-Frame-Options "SAMEORIGIN" always;
33+
add_header X-XSS-Protection "1; mode=block" always;
34+
add_header X-Content-Type-Options nosniff always;
35+
add_header Referrer-Policy "no-referrer-when-downgrade" always;
36+
37+
# Performance
38+
gzip on;
39+
gzip_comp_level 5;
40+
gzip_min_length 256;
41+
gzip_proxied any;
42+
gzip_vary on;
43+
gzip_types
44+
application/atom+xml
45+
application/javascript
46+
application/json
47+
application/ld+json
48+
application/manifest+json
49+
application/rss+xml
50+
application/geo+json
51+
application/vnd.ms-fontobject
52+
application/x-web-app-manifest+json
53+
application/xhtml+xml
54+
application/xml
55+
application/rdf+xml
56+
font/otf
57+
application/wasm
58+
image/bmp
59+
image/svg+xml
60+
text/cache-manifest
61+
text/css
62+
text/javascript
63+
text/plain
64+
text/markdown
65+
text/vcard
66+
text/calendar
67+
text/vnd.rim.location.xloc
68+
text/vtt
69+
text/x-component
70+
text/x-cross-domain-policy;
71+
72+
# Content types
73+
include mime.types;
74+
charset utf-8;
75+
charset_types
76+
text/css
77+
text/plain
78+
text/vnd.wap.wml
79+
text/javascript
80+
text/markdown
81+
text/calendar
82+
text/x-component
83+
text/vcard
84+
text/cache-manifest
85+
text/vtt
86+
application/json
87+
application/manifest+json;
88+
}

kubernetes/deployment.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,17 @@ spec:
229229
labels:
230230
app: code-home
231231
spec:
232+
securityContext:
233+
fsGroup: 101
232234
containers:
233235
- name: code-home
234-
image: grimbough/code.bioc-home:0.1.5
236+
image: grimbough/code.bioc-home:0.2.0
235237
imagePullPolicy: "Always"
236238
volumeMounts:
237239
- mountPath: "/var/shared"
238240
name: git-repo-shared-info
241+
- mountPath: "/var/log/nginx"
242+
name: nginx-logs
239243
ports:
240244
- name: http
241245
containerPort: 8080
@@ -251,7 +255,8 @@ spec:
251255
runAsNonRoot: true
252256
seccompProfile:
253257
type: RuntimeDefault
254-
runAsUser: 100 #lighttpd uid
258+
runAsUser: 101
259+
runAsGroup: 101
255260
allowPrivilegeEscalation: false
256261
capabilities:
257262
drop:
@@ -261,3 +266,6 @@ spec:
261266
persistentVolumeClaim:
262267
claimName: bioc-code-tools-shared-info-pvc
263268
readOnly: true
269+
- name: nginx-logs
270+
persistentVolumeClaim:
271+
claimName: nginx-logs

0 commit comments

Comments
 (0)