IBM Maximo: Containerized NGINX server with authentication to securely host and distribute customization files.zip: Difference between revisions

From Wiki
Jump to navigation Jump to search
Line 109: 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/my-file.zip"
curl -O "https://${NGINX_HOST}/files/my-file.zip"

Revision as of 17:48, 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/my-file.zip"

Via Service (Internal Cluster Access):

NGINX_HOST=http://nginx-fileserver.mas-nginx.svc:8080

curl -O "https://${NGINX_HOST}/files/my-file.zip"


6.1) List Available Files

curl "https://${NGINX_HOST}/files/"
# or internally:
curl "http://nginx-fileserver:8080/files/"

See also