You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have been trying to setup a simple html webpage to see if I can access publicly on the same VPS as Netmaker. I was able to edit the Caddyfile to point a domain to a service inside of my network which is great for that I would want access controlled. However, I also want to host a public website or landing page for anyone to see. Is this possible out-of-the-box ?
I have a feeling it's just the reverse-proxy part of the Caddyfile since I can point to an NPM instance when I know the desired IP, but I don't know how to point all traffic from 80/443 to the webpage unless a subdomain is given. Not sure if my /www directory is causing any issues as well... Thanks in advanced anyone that can help!
Here's what I've tried:
HTML /root/www/caddy.html
<html>
<head>
<title>Caddy tutorial</title>
</head>
<body>
Page loaded at: {{now | date "Mon Jan 2 15:04:05 MST 2006"}}
</body>
</html>
Caddyfile /root/Caddyfile
# Dashboard
https://dashboard.{$NM_DOMAIN} {
# Apply basic security headers
header {
# Enable cross origin access to *.{$NM_DOMAIN}
Access-Control-Allow-Origin *.{$NM_DOMAIN}
# Enable HTTP Strict Transport Security (HSTS)
Strict-Transport-Security "max-age=31536000;"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block"
# Disallow the site to be rendered within a frame on a foreign domain (clickjacking protection)
X-Frame-Options "SAMEORIGIN"
# Prevent search engines from indexing
X-Robots-Tag "none"
# Remove the server name
-Server
}
reverse_proxy http://netmaker-ui
}
# Netmaker Exporter
https://netmaker-exporter.{$NM_DOMAIN} {
reverse_proxy http://netmaker-exporter:8085
}
# Prometheus
https://prometheus.{$NM_DOMAIN} {
reverse_proxy http://prometheus:9090
}
# Grafana
https://grafana.{$NM_DOMAIN} {
reverse_proxy http://grafana:3000
}
# API
https://api.{$NM_DOMAIN} {
reverse_proxy http://netmaker:8081
}
# MQ
wss://broker.{$NM_DOMAIN} {
reverse_proxy ws://mq:8883
}
# Ngnix Local Proxy - This works
https://mydomain.com {
reverse_proxy 10.101.0.2:81 Netmaker node
# reverse_proxy 192.168.4.103:81 using Egress
# Public landing page - This does not work
https://myotherdomain.com {
root * /var/www
file_server
reverse_proxy 10.101.0.1:80
# Also tried:
# reverse_proxy :80
# reverse_proxy caddy:80
# reverse_proxy netmaker:80
# no reverse proxy directive
# encode zstd gzip
# templates
}
Docker-compose /root/docker-compose.yml
GNU nano 6.2 docker-compose.yml M
version: "3.4"
services:
netmaker:
container_name: netmaker
image: gravitl/netmaker:$SERVER_IMAGE_TAG
env_file: ./netmaker.env
restart: always
volumes:
- dnsconfig:/root/config/dnsconfig
- sqldata:/root/data
environment:
# config-dependant vars
- STUN_LIST=stun1.netmaker.io:3478,stun2.netmaker.io:3478,stun1.l.google.com:19302,stun2.l.google.com:19302
# The domain/host IP indicating the mq broker address
- BROKER_ENDPOINT=wss://broker.${NM_DOMAIN} # For EMQX broker use `BROKER_ENDPOINT=wss://broker.${NM_DOMAIN}/mqtt`
# For EMQX broker (uncomment the two lines below)
#- BROKER_TYPE=emqx
#- EMQX_REST_ENDPOINT=http://mq:18083
# The base domain of netmaker
- SERVER_NAME=${NM_DOMAIN}
- SERVER_API_CONN_STRING=api.${NM_DOMAIN}:443
# Address of the CoreDNS server. Defaults to SERVER_HOST
- COREDNS_ADDR=${SERVER_HOST}
# Overrides SERVER_HOST if set. Useful for making HTTP available via different interfaces/networks.
- SERVER_HTTP_HOST=api.${NM_DOMAIN}
netmaker-ui:
container_name: netmaker-ui
image: gravitl/netmaker-ui:$UI_IMAGE_TAG
env_file: ./netmaker.env
environment:
# config-dependant vars
# URL where UI will send API requests. Change based on SERVER_HOST, SERVER_HTTP_HOST, and API_PORT
BACKEND_URL: "https://api.${NM_DOMAIN}"
depends_on:
- netmaker
links:
- "netmaker:api"
restart: always
caddy:
image: caddy:2.6.2
container_name: caddy
env_file: ./netmaker.env
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_conf:/config
- ./www:/var/www
ports:
- "80:80"
- "443:443"
coredns:
#network_mode: host
container_name: coredns
image: coredns/coredns:1.10.1
command: -conf /root/dnsconfig/Corefile
env_file: ./netmaker.env
restart: always
depends_on:
- netmaker
volumes:
- dnsconfig:/root/dnsconfig
mq:
container_name: mq
image: eclipse-mosquitto:2.0.15-openssl
env_file: ./netmaker.env
depends_on:
- netmaker
restart: unless-stopped
command: [ "/mosquitto/config/wait.sh" ]
volumes:
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
- ./wait.sh:/mosquitto/config/wait.sh
- mosquitto_logs:/mosquitto/log
- mosquitto_data:/mosquitto/data
volumes:
caddy_data: { } # runtime data for caddy
caddy_conf: { } # configuration file for Caddy
sqldata: { }
dnsconfig: { } # storage for coredns
mosquitto_logs: { } # storage for mqtt logs
mosquitto_data: { } # storage for mqtt data
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I have been trying to setup a simple html webpage to see if I can access publicly on the same VPS as Netmaker. I was able to edit the Caddyfile to point a domain to a service inside of my network which is great for that I would want access controlled. However, I also want to host a public website or landing page for anyone to see. Is this possible out-of-the-box ?
I have a feeling it's just the reverse-proxy part of the Caddyfile since I can point to an NPM instance when I know the desired IP, but I don't know how to point all traffic from 80/443 to the webpage unless a subdomain is given. Not sure if my /www directory is causing any issues as well... Thanks in advanced anyone that can help!
Here's what I've tried:
HTML /root/www/caddy.html
Caddyfile /root/Caddyfile
Docker-compose /root/docker-compose.yml
Beta Was this translation helpful? Give feedback.
All reactions