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
 
(5 intermediate revisions by the same user not shown)
Line 38: Line 38:
  openssl rand -hex 32
  openssl rand -hex 32


Edit '''secret-upload-token.yaml''' and replace the value of <code>UPLOAD_TOKEN</code>:
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)  


<nowiki>NGINX_HOST=http://nginx-fileserver:8080/files/customization-files.zip</nowiki>
<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/my-file.zip"
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/my-file.zip"
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 ===


<syntaxhighlight lang="bash">
<nowiki>curl "https://${NGINX_HOST}/files/"</nowiki>
curl "https://${NGINX_HOST}/files/"
 
# or internally:
or internally:
curl "http://nginx-fileserver:8080/files/"
 
</syntaxhighlight>
<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/"

See also