-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support deployment behind NGINX reverse proxy
- Loading branch information
1 parent
bb5aa0a
commit a64790d
Showing
18 changed files
with
298 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://spring.io/guides/topicals/spring-boot-docker#_multi_stage_build | ||
FROM eclipse-temurin:17-jdk-alpine as build | ||
WORKDIR /workspace/app | ||
RUN apk add maven | ||
COPY pom.xml . | ||
COPY maven maven | ||
RUN mvn dependency:resolve -s maven/cnaf-mirror-settings.xml | ||
RUN mvn dependency:resolve-plugins -s maven/cnaf-mirror-settings.xml | ||
COPY .git .git | ||
COPY etc etc | ||
COPY src src | ||
RUN mvn package -s maven/cnaf-mirror-settings.xml -Dmaven.test.skip | ||
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) | ||
|
||
FROM eclipse-temurin:17-jdk-alpine | ||
VOLUME /tmp | ||
ARG DEPENDENCY=/workspace/app/target/dependency | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib | ||
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF | ||
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app | ||
COPY src src | ||
EXPOSE 8086 | ||
ENTRYPOINT ["java","-Dspring.profiles.active=dev","-cp","app:app/lib/*","org.italiangrid.storm.webdav.WebdavService"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
podman build -t storm-webdav . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
user nobody; | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log debug; | ||
|
||
load_module modules/ngx_http_voms_module.so; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
|
||
resolver 127.0.0.11 ipv6=off; | ||
|
||
log_format storm '$time_iso8601 [$request_id] $remote_addr - $remote_user "$request" <$upstream_response_time> ' | ||
'$ssl_protocol/$ssl_cipher ' | ||
'"$ssl_client_s_dn" ' | ||
'[$voms_fqans] ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log storm; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
server { | ||
location /internal { | ||
internal; | ||
alias /src/test/resources/storage/nginx; | ||
} | ||
location / { | ||
proxy_pass http://storm-webdav:8086; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-VOMS-voms_user $voms_user; | ||
proxy_set_header X-VOMS-ssl_client_ee_s_dn $ssl_client_ee_s_dn; | ||
proxy_set_header X-VOMS-voms_user_ca $voms_user_ca; | ||
proxy_set_header X-VOMS-ssl_client_ee_i_dn $ssl_client_ee_i_dn; | ||
proxy_set_header X-VOMS-voms_fqans $voms_fqans; | ||
proxy_set_header X-VOMS-voms_server $voms_server; | ||
proxy_set_header X-VOMS-voms_server_ca $voms_server_ca; | ||
proxy_set_header X-VOMS-voms_vo $voms_vo; | ||
proxy_set_header X-VOMS-voms_server_uri $voms_server_uri; | ||
proxy_set_header X-VOMS-voms_not_before $voms_not_before; | ||
proxy_set_header X-VOMS-voms_not_after $voms_not_after; | ||
proxy_set_header X-VOMS-voms_generic_attributes $voms_generic_attributes; | ||
proxy_set_header X-VOMS-voms_serial $voms_serial; | ||
proxy_redirect off; | ||
} | ||
listen [::]:8443 ssl http2; | ||
listen 8443 ssl http2; | ||
ssl_certificate /etc/grid-security/hostcert.pem; | ||
ssl_certificate_key /etc/grid-security/hostkey.pem; | ||
ssl_client_certificate /etc/pki/ca-trust/extracted/pem/tls-ca-bundle-all.pem; | ||
ssl_verify_client optional; | ||
ssl_verify_depth 10; | ||
error_page 497 https://$host:8443$request_uri; # https://ma.ttias.be/force-redirect-http-https-custom-port-nginx/#forcing-https-redirects-on-non-standard-ports | ||
} | ||
server { | ||
location /internal { | ||
internal; | ||
alias /src/test/resources/storage/nginx; | ||
} | ||
location / { | ||
proxy_pass http://127.0.0.1:8086; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
} | ||
listen [::]:8085; | ||
listen 8085; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/DC=org/DC=terena/DC=tcs/C=IT/ST=Roma/O=Istituto Nazionale di Fisica Nucleare/CN=wlcg-voms.cloud.cnaf.infn.it | ||
/C=NL/O=GEANT Vereniging/CN=GEANT eScience SSL CA 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
services: | ||
trust: | ||
image: indigoiam/egi-trustanchors:igi-test-ca | ||
volumes: | ||
- trustanchors:/etc/grid-security/certificates | ||
- cabundle:/etc/pki | ||
environment: | ||
- FORCE_TRUST_ANCHORS_UPDATE=1 | ||
nginx-httpg-voms: | ||
image: cnafsd/nginx-httpg-voms | ||
volumes: | ||
- /etc/grid-security/hostcert.pem:/etc/grid-security/hostcert.pem:ro | ||
- /etc/grid-security/hostkey.pem:/etc/grid-security/hostkey.pem:ro | ||
- trustanchors:/etc/grid-security/certificates | ||
- cabundle:/etc/pki | ||
- ../src:/src:z | ||
- ./assets/nginx/nginx.conf:/etc/nginx/nginx.conf:z | ||
- ./assets/nginx/storm.conf:/etc/nginx/conf.d/storm.conf:z | ||
- ./assets/wlcg:/etc/grid-security/vomsdir/wlcg:z | ||
ports: | ||
- "8443:8443" | ||
# to wait the trust service to finish | ||
restart: on-failure | ||
storm-webdav: | ||
build: | ||
context: ../ | ||
dockerfile: Dockerfile | ||
|
||
volumes: | ||
trustanchors: | ||
cabundle: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
podman-compose up trust | ||
podman-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[nginx-stable] | ||
name=nginx stable repo | ||
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ | ||
gpgcheck=1 | ||
enabled=1 | ||
gpgkey=https://nginx.org/keys/nginx_signing.key | ||
module_hotfixes=true | ||
|
||
[nginx-mainline] | ||
name=nginx mainline repo | ||
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ | ||
gpgcheck=1 | ||
enabled=0 | ||
gpgkey=https://nginx.org/keys/nginx_signing.key | ||
module_hotfixes=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
podman stop storm-webdav; podman rm storm-webdav; podman run -d -p 8085:8085 -p 8443:8443 -p 8086:8086 --name storm-webdav localhost/storm-webdav:latest |
42 changes: 42 additions & 0 deletions
42
src/main/java/org/italiangrid/storm/webdav/authz/VOMSNginxFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) Istituto Nazionale di Fisica Nucleare, 2014-2023. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.italiangrid.storm.webdav.authz; | ||
|
||
import javax.security.auth.x500.X500Principal; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.springframework.security.authentication.AuthenticationManager; | ||
|
||
public class VOMSNginxFilter extends VOMSAuthenticationFilter { | ||
|
||
public VOMSNginxFilter(AuthenticationManager mgr) { | ||
super(mgr); | ||
} | ||
|
||
@Override | ||
protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) { | ||
if (request.getHeader("X-VOMS-voms_user") != null) { | ||
return new X500Principal(request.getHeader("X-VOMS-ssl_client_ee_s_dn")).getName(); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
protected Object getPreAuthenticatedCredentials(HttpServletRequest request) { | ||
return new Object(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.