Skip to content

Commit ca1092a

Browse files
committed
move monitor endpoint to be http
1 parent 65aefcf commit ca1092a

File tree

2 files changed

+11
-58
lines changed

2 files changed

+11
-58
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ The bootstrap script installs MongoDB, configures it with proper security settin
146146

147147
## Step 2: Provision TLS Certificates
148148

149-
The provision_ssl script configures MongoDB to use pre-generated private CA certificates for enhanced security. These can be generated using the mongodb-ssl tools on your machine.
149+
The provision_ssl script configures MongoDB to use pre-generated private CA certificates for enhanced security instead of Let's Encrypt certificates. This approach provides better security and easier maintenance for MongoDB deployments.
150150

151151
1. **Place your private CA certificates in the required locations**:
152152

@@ -268,12 +268,14 @@ The monitoring script sets up email alerts and a monitoring endpoint for your Mo
268268

269269
3. **Access the monitoring endpoint**:
270270

271-
You can access the monitoring endpoint at:
271+
You can access the monitoring endpoint via HTTP at:
272272
```
273273
http://your-domain.com/monitor?token=your_secure_monitor_token
274274
```
275275

276276
Replace `your_secure_monitor_token` with the value you set in `config.json`.
277+
278+
Note: The monitoring endpoint is only available over HTTP, not HTTPS, as it uses a simple configuration that doesn't require SSL certificates.
277279

278280
4. **Email alerts**:
279281

monitoring.sh

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ EOF
186186

187187
sudo chmod +x /usr/local/bin/mongo_monitor.sh
188188

189-
# NOTE: Configure nginx for the monitor endpoint
190-
echo "Configuring nginx for the monitoring endpoint..."
189+
# NOTE: Configure nginx for the monitor endpoint (HTTP only)
190+
echo "Configuring nginx for the monitoring endpoint (HTTP only)..."
191191
cat <<EOF | sudo tee /etc/nginx/conf.d/monitor.conf
192-
# This configuration adds the /monitor endpoint to both HTTP and HTTPS servers
192+
# This configuration adds the /monitor endpoint to HTTP server
193193
194194
# For HTTP
195195
server {
@@ -202,62 +202,14 @@ server {
202202
fastcgi_param SCRIPT_FILENAME /usr/local/bin/mongo_monitor.sh;
203203
}
204204
}
205-
206-
# For HTTPS (if private CA certificates are set up)
207-
server {
208-
listen 443 ssl;
209-
server_name $DOMAIN;
210-
211-
# These SSL settings will be ignored if the certificate files don't exist
212-
ssl_certificate /etc/ssl/mongodb/certificate_authority.pem;
213-
ssl_certificate_key /etc/ssl/mongodb/certificate.pem;
214-
215-
location = /monitor {
216-
fastcgi_pass unix:/var/run/fcgiwrap.socket;
217-
include fastcgi_params;
218-
fastcgi_param SCRIPT_FILENAME /usr/local/bin/mongo_monitor.sh;
219-
}
220-
}
221205
EOF
222206

223-
# Fix the configuration if the include_if_exists directive is not supported
207+
# Fix the configuration if needed
224208
if ! nginx -t 2>/dev/null; then
225-
echo "Detected older nginx version without include_if_exists support. Adjusting configuration..."
209+
echo "Detected nginx configuration issue. Adjusting configuration..."
226210

227-
# Check if SSL certificates exist
228-
if [ -f "/etc/ssl/mongodb/certificate_authority.pem" ] && [ -f "/etc/ssl/mongodb/certificate.pem" ]; then
229-
# Create a configuration with both HTTP and HTTPS
230-
cat <<EOF | sudo tee /etc/nginx/conf.d/monitor.conf
231-
# For HTTP
232-
server {
233-
listen 80;
234-
server_name $DOMAIN;
235-
236-
location = /monitor {
237-
fastcgi_pass unix:/var/run/fcgiwrap.socket;
238-
include fastcgi_params;
239-
fastcgi_param SCRIPT_FILENAME /usr/local/bin/mongo_monitor.sh;
240-
}
241-
}
242-
243-
# For HTTPS
244-
server {
245-
listen 443 ssl;
246-
server_name $DOMAIN;
247-
248-
ssl_certificate /etc/ssl/mongodb/certificate_authority.pem;
249-
ssl_certificate_key /etc/ssl/mongodb/certificate.pem;
250-
251-
location = /monitor {
252-
fastcgi_pass unix:/var/run/fcgiwrap.socket;
253-
include fastcgi_params;
254-
fastcgi_param SCRIPT_FILENAME /usr/local/bin/mongo_monitor.sh;
255-
}
256-
}
257-
EOF
258-
else
259-
# Create a configuration with only HTTP
260-
cat <<EOF | sudo tee /etc/nginx/conf.d/monitor.conf
211+
# Create a configuration with only HTTP
212+
cat <<EOF | sudo tee /etc/nginx/conf.d/monitor.conf
261213
server {
262214
listen 80;
263215
server_name $DOMAIN;
@@ -269,7 +221,6 @@ server {
269221
}
270222
}
271223
EOF
272-
fi
273224
fi
274225

275226
# NOTE: Test and reload nginx

0 commit comments

Comments
 (0)