Files
myceliumcloud-examples/examples/nginx-mycelium/nginx-proxy-clean

164 lines
5.4 KiB
Plaintext

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-mycelium-proxy
namespace: default
labels:
app: nginx-mycelium-proxy
role: reverse-proxy
spec:
replicas: 3
selector:
matchLabels:
app: nginx-mycelium-proxy
template:
metadata:
labels:
app: nginx-mycelium-proxy
role: reverse-proxy
spec:
hostNetwork: true
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginx-mycelium-proxy
topologyKey: kubernetes.io/hostname
containers:
- name: nginx-proxy
image: nginx:alpine
ports:
- containerPort: 8080
hostPort: 8080
- containerPort: 8081
hostPort: 8081
- containerPort: 8082
hostPort: 8082
volumeMounts:
- name: proxy-conf
mountPath: /etc/nginx/conf.d/default.conf
- name: proxy-html
mountPath: /usr/share/nginx/html
resources:
requests:
memory: "32Mi"
cpu: "100m"
limits:
memory: "64Mi"
cpu: "200m"
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
volumes:
- name: proxy-conf
configMap:
name: nginx-proxy-conf
- name: proxy-html
configMap:
name: nginx-proxy-html
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-proxy-conf
namespace: default
data:
default.conf: |
upstream backend {
server nginx-mycelium.default.svc.cluster.local:80;
}
server {
listen 8080;
server_name _;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 8081;
server_name _;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 8082;
server_name _;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-proxy-html
namespace: default
data:
index.html: |
<!DOCTYPE html>
<html>
<head>
<title>🌍 Mycelium Global Access - Reverse Proxy Success</title>
<meta charset="UTF-8">
<style>
body { font-family: Arial, sans-serif; margin: 50px; background: #f0f0f0; }
.container { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); max-width: 800px; margin: 0 auto; }
h1 { color: #2c3e50; text-align: center; }
.success { background: #e8f4fd; padding: 20px; border-radius: 8px; border-left: 4px solid #3498db; margin: 20px 0; }
.urls { background: #fff3cd; padding: 20px; border-radius: 8px; border-left: 4px solid #ffc107; margin: 20px 0; }
code { background: #f8f9fa; padding: 2px 4px; border-radius: 3px; font-size: 12px; }
</style>
</head>
<body>
<div class="container">
<h1>🌍 Mycelium Reverse Proxy - Global Access</h1>
<div class="success">
<h2>✅ SUCCESS! Reverse Proxy Working</h2>
<p><strong>This nginx reverse proxy is forwarding requests to the internal nginx-mycelium service!</strong></p>
<p>The reverse proxy approach provides true global access while maintaining Kubernetes load balancing.</p>
</div>
<div class="urls">
<h3>🌐 Global Access URLs</h3>
<p><strong>Test the reverse proxy from anywhere:</strong></p>
<ul style="font-size: 12px;">
<li><code>http://[51d:3596:6cc3:81e7:ff0f:d546:3737:4c8c]:8080</code></li>
<li><code>http://[476:c4f:b4cb:7205:ff0f:f56e:abea:6905]:8080</code></li>
<li><code>http://[538:964a:a1e1:4057:ff0f:63c7:960b:7c27]:8081</code></li>
<li><code>http://[552:5984:2d97:72dc:ff0f:39ef:6ec:a48c]:8081</code></li>
<li><code>http://[437:9faf:1f1a:e2b1:ff0f:1fd9:7fd5:1095]:8082</code></li>
<li><code>http://[5c3:a162:45ab:6c53:ff0f:8c55:36b0:24af]:8082</code></li>
</ul>
<p><em>All requests are forwarded to internal nginx-mycelium service with load balancing!</em></p>
</div>
<div style="text-align: center; margin-top: 30px;">
<p><strong>Mycelium Cloud</strong> • Reverse Proxy Architecture • Global Web Hosting 🌍</p>
</div>
</div>
</body>
</html>