IBM Maximo: Containerized NGINX server with authentication to securely host and distribute customization files.zip: Difference between revisions
Jump to navigation
Jump to search
| (6 intermediate revisions by the same user not shown) | |||
| Line 24: | Line 24: | ||
== 1) Clone repository == | == 1) Clone repository == | ||
Edit '''secret-upload-token.yaml''' and replace the value of | Edit '''secret-upload-token.yaml''' and replace the value of '''UPLOAD_TOKEN''': | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 38: | Line 38: | ||
openssl rand -hex 32 | openssl rand -hex 32 | ||
Edit '''secret-upload-token.yaml''' and replace the value of | Edit '''secret-upload-token.yaml''' and replace the value of '''UPLOAD_TOKEN''': | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
| Line 86: | Line 86: | ||
Via Service (Internal Cluster Access) | Via Service (Internal Cluster Access) | ||
<syntaxhighlight lang="bash"> | |||
NGINX_HOST=http://nginx-fileserver.mas-nginx.svc:8080 | |||
TOKEN="replace-with-a-secure-token" | |||
curl -v \ | |||
-X PUT \ | |||
-H "X-Upload-Token: ${TOKEN}" \ | |||
-H "Content-Type: application/octet-stream" \ | |||
--upload-file ./customization-files.zip \ | |||
"https://${NGINX_HOST}/files/customization-files.zip" | |||
</syntaxhighlight> | |||
== 6) Download a File with curl == | == 6) Download a File with curl == | ||
| Line 93: | Line 103: | ||
NGINX_HOST=$(oc get route nginx-fileserver -o jsonpath='{.spec.host}') | NGINX_HOST=$(oc get route nginx-fileserver -o jsonpath='{.spec.host}') | ||
curl -O "https://${NGINX_HOST}/files/ | curl -O "https://${NGINX_HOST}/files/customization-files.zip" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 99: | Line 109: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
NGINX_HOST=http://nginx-fileserver:8080 | NGINX_HOST=http://nginx-fileserver.mas-nginx.svc:8080 | ||
curl -O "https://${NGINX_HOST}/files/ | curl -O "https://${NGINX_HOST}/files/customization-files.zip" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 107: | Line 117: | ||
=== 6.1) List Available Files === | === 6.1) List Available Files === | ||
< | <nowiki>curl "https://${NGINX_HOST}/files/"</nowiki> | ||
curl "https://${NGINX_HOST}/files/" | |||
or internally: | |||
curl "http://nginx-fileserver:8080/files/" | |||
</ | <nowiki>curl "http://nginx-fileserver.mas-nginx.svc:8080/files/"</nowiki> | ||
= See also = | = See also = | ||
Latest revision as of 17:50, 6 July 2026
Nginx container running on OpenShift to provide customization_files.zip file sharing between containers, with token-protected uploads.
Architecture
[ curl / another container ]
│
PUT /files/<filename> ← protected by X-Upload-Token
GET /files/<filename> ← public (download)
│
┌──────▼───────────────────────┐
│ nginx-fileserver Pod │
│ image: nginx-unprivileged │
│ port: 8080 │
└──────────────────────────────┘
│
PersistentVolumeClaim: /data/files
Procedure
1) Clone repository
Edit secret-upload-token.yaml and replace the value of UPLOAD_TOKEN:
git clone https://github.com/ebasso/mas-nginx-customization-file-server.git
cd mas-nginx-customization-file-server/yamls
2) Configure the Secret Token
Generate a strong token using
openssl rand -hex 32
Edit secret-upload-token.yaml and replace the value of UPLOAD_TOKEN:
stringData:
UPLOAD_TOKEN: "replace-with-a-secure-token"
3) Full Deployment
oc new-project mas-nginx
# Apply all resources in the correct order
oc apply -f secret-upload-token.yaml
oc apply -f configmap-nginx.yaml
oc apply -f pvc-nginx-files.yaml
oc apply -f deployment-nginx.yaml
oc apply -f service-nginx.yaml
oc apply -f route-nginx.yaml
4) Verify the Route URL
oc get route nginx-fileserver -o jsonpath='{.spec.host}'
Example: nginx-fileserver-mas-nginx.apps.cluster.example.com
5) Upload a File with curl
Via Route (External Access)
NGINX_HOST=$(oc get route nginx-fileserver -o jsonpath='{.spec.host}')
TOKEN="replace-with-a-secure-token"
curl -v \
-X PUT \
-H "X-Upload-Token: ${TOKEN}" \
-H "Content-Type: application/octet-stream" \
--upload-file ./customization-files.zip \
"https://${NGINX_HOST}/files/customization-files.zip"
Via Service (Internal Cluster Access)
NGINX_HOST=http://nginx-fileserver.mas-nginx.svc:8080
TOKEN="replace-with-a-secure-token"
curl -v \
-X PUT \
-H "X-Upload-Token: ${TOKEN}" \
-H "Content-Type: application/octet-stream" \
--upload-file ./customization-files.zip \
"https://${NGINX_HOST}/files/customization-files.zip"
6) Download a File with curl
NGINX_HOST=$(oc get route nginx-fileserver -o jsonpath='{.spec.host}')
curl -O "https://${NGINX_HOST}/files/customization-files.zip"
Via Service (Internal Cluster Access):
NGINX_HOST=http://nginx-fileserver.mas-nginx.svc:8080
curl -O "https://${NGINX_HOST}/files/customization-files.zip"
6.1) List Available Files
curl "https://${NGINX_HOST}/files/"
or internally:
curl "http://nginx-fileserver.mas-nginx.svc:8080/files/"