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
Created page with "Nginx container running on OpenShift to provide '''customization_files.zip''' file sharing between containers, with token-protected uploads. = Architecture = <pre> [ curl / another container ] │ PUT /files/<filename> ← protected by X-Upload-Token GET /files/<filename> ← public (download) │ ┌──────▼───────────────────────┐ │ nginx-fileserver Pod..."
 
 
(15 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 <code>UPLOAD_TOKEN</code>:
Edit '''secret-upload-token.yaml''' and replace the value of '''UPLOAD_TOKEN''':


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 34: Line 34:
== 2) Configure the Secret Token ==
== 2) Configure the Secret Token ==


Edit '''secret-upload-token.yaml''' and replace the value of <code>UPLOAD_TOKEN</code>:
Generate a strong token using
 
openssl rand -hex 32
 
Edit '''secret-upload-token.yaml''' and replace the value of '''UPLOAD_TOKEN''':


<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
Line 40: Line 44:
   UPLOAD_TOKEN: "replace-with-a-secure-token"
   UPLOAD_TOKEN: "replace-with-a-secure-token"
</syntaxhighlight>
</syntaxhighlight>
: Note: Generate a strong token using <code>openssl rand -hex 32</code>.


== 3) Full Deployment ==
== 3) Full Deployment ==
Line 55: Line 57:
oc apply -f service-nginx.yaml
oc apply -f service-nginx.yaml
oc apply -f route-nginx.yaml
oc apply -f route-nginx.yaml
</syntaxhighlight>
</syntaxhighlight>


----


== 3 — Verify the Route URL ==
== 4) Verify the Route URL ==


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
oc get route nginx-fileserver -o jsonpath='{.spec.host}'
oc get route nginx-fileserver -o jsonpath='{.spec.host}'
# Example:
# nginx-fileserver-mas-nginx.apps.cluster.example.com
</syntaxhighlight>
</syntaxhighlight>


----
Example: <nowiki>nginx-fileserver-mas-nginx.apps.cluster.example.com</nowiki>


== 4)Upload a File with curl ==
== 5) Upload a File with curl ==


Via Route (External Access)
Via Route (External Access)
Line 88: Line 86:
Via Service (Internal Cluster Access)  
Via Service (Internal Cluster Access)  


: NGINX_HOST=http://nginx-fileserver:8080/files/customization-files.zip
<syntaxhighlight lang="bash">
NGINX_HOST=http://nginx-fileserver.mas-nginx.svc:8080
TOKEN="replace-with-a-secure-token"


== 5 — Download a File with curl ==
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 ==


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
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>


Via Service (Internal Cluster Access):
Via Service (Internal Cluster Access):
: NGINX_HOST=http://nginx-fileserver:8080/files/customization-files.zip


=== 5.1 — List Available Files ===
<syntaxhighlight lang="bash">
NGINX_HOST=http://nginx-fileserver.mas-nginx.svc:8080


<syntaxhighlight lang="bash">
curl -O "https://${NGINX_HOST}/files/customization-files.zip"
curl "https://${NGINX_HOST}/files/"
# or internally:
curl "http://nginx-fileserver:8080/files/"
</syntaxhighlight>
</syntaxhighlight>




=== 6.1) List Available Files ===
<nowiki>curl "https://${NGINX_HOST}/files/"</nowiki>
or internally:
<nowiki>curl "http://nginx-fileserver.mas-nginx.svc:8080/files/"</nowiki>


= See Alson também =
= See also =


* [[Cloud| Artigos sobre Cloud]]
* [[Cloud| Artigos sobre Cloud]]

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