Add SOCKS proxy support for certificate renewal without internet access
- Configure Traefik to use SOCKS/HTTP proxy for Let's Encrypt ACME challenges - Add proxy environment variables (SOCKS_PROXY, HTTP_PROXY, HTTPS_PROXY, NO_PROXY) - Update docker-compose.yml to pass proxy vars to Traefik container - Update entrypoint script to log proxy configuration - Document proxy setup in .env.example - Add comprehensive guide: PROXY_CERTIFICATE_RENEWAL.md with SSH tunnel setup instructions
This commit is contained in:
14
.env.example
14
.env.example
@@ -70,6 +70,20 @@ TRAEFIK_ACCESS_LOG=
|
||||
# Configure the log level for Traefik.
|
||||
# Possible values are "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL" and "PANIC". Default is "ERROR".
|
||||
TRAEFIK_LOG_LEVEL=
|
||||
# Proxy configuration for Traefik (when server has no direct internet access)
|
||||
# Use these variables when you need to route Traefik traffic through a proxy
|
||||
# Example for SOCKS5 proxy: SOCKS_PROXY=socks5://localhost:18080
|
||||
# Example for HTTP proxy: HTTP_PROXY=http://localhost:8080
|
||||
# Note: Set up SSH tunnel to forward your local proxy to the server:
|
||||
# ssh -R 18080:127.0.0.1:18080 -N -T user@server
|
||||
# Then on the server, set:
|
||||
# SOCKS_PROXY=socks5://localhost:18080
|
||||
# HTTP_PROXY=http://localhost:18080
|
||||
# HTTPS_PROXY=http://localhost:18080
|
||||
SOCKS_PROXY=
|
||||
HTTP_PROXY=
|
||||
HTTPS_PROXY=
|
||||
NO_PROXY=localhost,127.0.0.1,172.16.0.0/12,10.0.0.0/8
|
||||
|
||||
|
||||
## OpenCloud Settings ##
|
||||
|
||||
13
.vscode/settings.json
vendored
13
.vscode/settings.json
vendored
@@ -1,3 +1,14 @@
|
||||
{
|
||||
"github.copilot.chat.commitMessageGeneration.instructions": []
|
||||
"github.copilot.chat.commitMessageGeneration.instructions": [],
|
||||
"chat.tools.terminal.autoApprove": {
|
||||
"env": true,
|
||||
"docker exec": true,
|
||||
"mkcert": true,
|
||||
"mkdir": true,
|
||||
"openssl": true,
|
||||
"md5sum": true,
|
||||
"tea": true,
|
||||
"true": true,
|
||||
"git symbolic-ref": true
|
||||
}
|
||||
}
|
||||
242
PROXY_CERTIFICATE_RENEWAL.md
Normal file
242
PROXY_CERTIFICATE_RENEWAL.md
Normal file
@@ -0,0 +1,242 @@
|
||||
# Certificate Renewal via SOCKS Proxy
|
||||
|
||||
This guide explains how to renew Let's Encrypt certificates on a production server without direct internet access by using a SOCKS proxy tunneled through SSH.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- SSH access to your production server
|
||||
- A machine with internet access and a SOCKS5 proxy running (e.g., on port 18080)
|
||||
- Docker Compose running on the production server
|
||||
- Traefik configured with Let's Encrypt certificate resolver
|
||||
|
||||
## Step 1: Establish SSH Tunnel for SOCKS Proxy
|
||||
|
||||
From your local machine with internet access, establish a reverse SSH tunnel that forwards your SOCKS proxy to the production server:
|
||||
|
||||
### Option A: Foreground tunnel (for testing/debugging)
|
||||
```bash
|
||||
ssh -R 18080:127.0.0.1:18080 -N -T user@production-server.com
|
||||
```
|
||||
|
||||
This command:
|
||||
- `-R 18080:127.0.0.1:18080` - Creates a reverse tunnel binding port 18080 on the remote server to localhost:18080 on your machine
|
||||
- `-N` - Doesn't execute remote commands
|
||||
- `-T` - Disables pseudo-terminal allocation
|
||||
- Keeps the tunnel open while the command runs
|
||||
|
||||
### Option B: Background persistent tunnel
|
||||
```bash
|
||||
# Using autossh for auto-reconnection
|
||||
autossh -M 20000 -R 18080:127.0.0.1:18080 -N -T user@production-server.com &
|
||||
|
||||
# Or with regular ssh (will disconnect if connection drops):
|
||||
ssh -R 18080:127.0.0.1:18080 -N -T user@production-server.com &
|
||||
```
|
||||
|
||||
### Option C: Systemd service (for permanent setup)
|
||||
|
||||
Create `/etc/systemd/system/ssh-proxy-tunnel.service`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=SSH Proxy Tunnel to Production Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=youruser
|
||||
ExecStart=/usr/bin/ssh -R 18080:127.0.0.1:18080 -N -T user@production-server.com
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
Environment="SSHPASS=your_password"
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Then enable and start it:
|
||||
```bash
|
||||
sudo systemctl enable ssh-proxy-tunnel.service
|
||||
sudo systemctl start ssh-proxy-tunnel.service
|
||||
```
|
||||
|
||||
## Step 2: Configure Environment Variables on Server
|
||||
|
||||
SSH into your production server and edit `.env`:
|
||||
|
||||
```bash
|
||||
ssh user@production-server.com
|
||||
cd /path/to/opencloud-compose
|
||||
nano .env
|
||||
```
|
||||
|
||||
Add the proxy configuration:
|
||||
|
||||
```bash
|
||||
# SOCKS5 proxy configuration (matches the reverse tunnel)
|
||||
SOCKS_PROXY=socks5://localhost:18080
|
||||
|
||||
# HTTP proxy (for systems that don't support SOCKS)
|
||||
# You can use a SOCKS-to-HTTP converter if needed, or use an HTTP proxy directly
|
||||
HTTP_PROXY=http://localhost:18080
|
||||
HTTPS_PROXY=http://localhost:18080
|
||||
|
||||
# Don't use proxy for these addresses
|
||||
NO_PROXY=localhost,127.0.0.1,172.16.0.0/12,10.0.0.0/8
|
||||
```
|
||||
|
||||
## Step 3: Restart Traefik to Apply Proxy Configuration
|
||||
|
||||
```bash
|
||||
# Restart the Traefik service
|
||||
docker compose restart traefik
|
||||
|
||||
# Check logs to verify proxy is being used
|
||||
docker compose logs -f traefik | grep -i proxy
|
||||
```
|
||||
|
||||
## Step 4: Trigger Certificate Renewal
|
||||
|
||||
Traefik automatically renews certificates 30 days before expiration. To manually force a renewal:
|
||||
|
||||
### Option A: Delete existing certificate and restart
|
||||
```bash
|
||||
# Backup the certificate file
|
||||
docker compose exec traefik cp /certs/acme.json /certs/acme.json.backup
|
||||
|
||||
# Remove the certificate to force renewal
|
||||
docker compose exec traefik rm /certs/acme.json
|
||||
|
||||
# Restart Traefik
|
||||
docker compose restart traefik
|
||||
|
||||
# Monitor the renewal process
|
||||
docker compose logs -f traefik | tail -50
|
||||
```
|
||||
|
||||
### Option B: Trigger renewal with curl (if Traefik API is enabled)
|
||||
```bash
|
||||
# Wait a moment for Traefik to start renewal
|
||||
sleep 30
|
||||
|
||||
# Check certificate status
|
||||
docker compose exec traefik curl -s http://localhost:8080/api/raw | jq '.
|
||||
[store][default].Certificates[0]'
|
||||
```
|
||||
|
||||
### Option C: Update certificate expiration date (force immediate renewal)
|
||||
```bash
|
||||
# Modify the acme.json to force renewal on next restart
|
||||
docker compose exec traefik /bin/sh -c 'sed -i "s/\"IssuedAt\"/\"IssuedAt_old\"/g" /certs/acme.json'
|
||||
|
||||
# Restart Traefik
|
||||
docker compose restart traefik
|
||||
|
||||
# Monitor logs
|
||||
docker compose logs -f traefik
|
||||
```
|
||||
|
||||
## Step 5: Verify Certificate Renewal
|
||||
|
||||
Check if the certificate was renewed successfully:
|
||||
|
||||
```bash
|
||||
# Check the certificate details
|
||||
docker compose exec traefik openssl x509 -in /certs/acme.json -text -noout
|
||||
|
||||
# Or check the certificate served by HTTPS
|
||||
echo | openssl s_client -servername your-domain.com -connect localhost:443 2>/dev/null | openssl x509 -noout -dates
|
||||
|
||||
# Check Traefik logs for any errors
|
||||
docker compose logs traefik | grep -i "acme\|certificate\|error"
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Proxy Connection Issues
|
||||
|
||||
If you see proxy-related errors in the logs:
|
||||
|
||||
```bash
|
||||
# Verify SSH tunnel is still active on local machine
|
||||
ps aux | grep ssh
|
||||
|
||||
# Check if tunnel is accessible from server
|
||||
ssh user@production-server.com
|
||||
curl -x socks5://localhost:18080 https://acme-v02.api.letsencrypt.org/directory
|
||||
|
||||
# If connection is refused, re-establish the tunnel
|
||||
```
|
||||
|
||||
### Certificate Renewal Fails
|
||||
|
||||
1. **Check Traefik logs:**
|
||||
```bash
|
||||
docker compose logs traefik | grep -A 5 -i "error\|acme"
|
||||
```
|
||||
|
||||
2. **Verify ACME configuration:**
|
||||
```bash
|
||||
docker compose exec traefik traefik --help | grep -i acme
|
||||
```
|
||||
|
||||
3. **Test Let's Encrypt staging environment first:**
|
||||
Add to `.env`:
|
||||
```
|
||||
TRAEFIK_ACME_CASERVER=https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
```
|
||||
Then restart and test. Once working, switch back to production.
|
||||
|
||||
4. **Check firewall rules:**
|
||||
```bash
|
||||
# Ensure outbound HTTPS traffic can reach Let's Encrypt
|
||||
curl -x socks5://localhost:18080 -v https://acme-v02.api.letsencrypt.org/directory
|
||||
```
|
||||
|
||||
### Common Errors
|
||||
|
||||
**"no such file or directory: acme.json"**
|
||||
- This is normal on first run. Traefik will create it.
|
||||
|
||||
**"x509: certificate signed by unknown authority"**
|
||||
- Set `INSECURE=true` temporarily for testing, or ensure your SOCKS proxy returns valid certificates.
|
||||
|
||||
**"Timeout waiting for HTTP challenge"**
|
||||
- Ensure port 80 is accessible on the server and the domain is pointing to the correct IP.
|
||||
|
||||
## Cleanup After Certificate Renewal
|
||||
|
||||
Once the certificate is renewed successfully:
|
||||
|
||||
1. Stop the SSH tunnel on your local machine (if it was temporary):
|
||||
```bash
|
||||
pkill ssh # Kill the tunnel process
|
||||
```
|
||||
|
||||
2. Remove the proxy configuration from `.env`:
|
||||
```bash
|
||||
# Comment out or remove these lines
|
||||
#SOCKS_PROXY=
|
||||
#HTTP_PROXY=
|
||||
#HTTPS_PROXY=
|
||||
```
|
||||
|
||||
3. Restart Traefik to operate without proxy:
|
||||
```bash
|
||||
docker compose restart traefik
|
||||
```
|
||||
|
||||
## Next Renewal (30 days before expiration)
|
||||
|
||||
Traefik will automatically attempt renewal 30 days before expiration. If the server still doesn't have internet access, repeat the process above.
|
||||
|
||||
For permanent solutions with servers without internet access, consider:
|
||||
- Deploying a local Let's Encrypt-compatible CA
|
||||
- Using wildcard certificates with DNS challenge instead of HTTP challenge
|
||||
- Implementing a reverse proxy with internet access that handles ACME challenges
|
||||
|
||||
## References
|
||||
|
||||
- [Traefik ACME Documentation](https://doc.traefik.io/traefik/https/acme/)
|
||||
- [Let's Encrypt Challenge Types](https://letsencrypt.org/docs/challenge-types/)
|
||||
- [SSH Port Forwarding Guide](https://linux.die.net/man/1/ssh)
|
||||
21
check_menus.py
Normal file
21
check_menus.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import logging
|
||||
logging.getLogger('odoo').setLevel(logging.CRITICAL)
|
||||
|
||||
xmlids = ['mrp_lot_mix.menu_mrp_lot_mix_root', 'mrp_lot_mix.menu_mrp_lot_mix']
|
||||
for xmlid in xmlids:
|
||||
try:
|
||||
menu = env.ref(xmlid)
|
||||
groups = ", ".join(menu.group_ids.mapped('display_name'))
|
||||
groups = groups or 'No groups'
|
||||
print(f"XMLID: {xmlid}, Name: {menu.name}, Groups: {groups}")
|
||||
except ValueError:
|
||||
print(f"XMLID: {xmlid} not found")
|
||||
|
||||
print("\n--- Group Details: mrp.group_mrp_user ---")
|
||||
try:
|
||||
group = env.ref('mrp.group_mrp_user')
|
||||
print(f"Group: {group.display_name}, XMLID: mrp.group_mrp_user")
|
||||
users = ", ".join(env['res.users'].search([('groups_id', 'in', group.id)]).mapped('name'))
|
||||
print(f"Users in group: {users}")
|
||||
except ValueError:
|
||||
print("Group mrp.group_mrp_user not found")
|
||||
8
check_modules.py
Normal file
8
check_modules.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import logging
|
||||
logging.getLogger('odoo').setLevel(logging.CRITICAL)
|
||||
|
||||
module = env['ir.module.module'].search([('name', '=', 'mrp_lot_mix')])
|
||||
if module:
|
||||
print(f"Module: {module.name}, State: {module.state}")
|
||||
else:
|
||||
print("Module mrp_lot_mix not found")
|
||||
@@ -38,6 +38,13 @@ if [ "${TRAEFIK_SERVICES_TLS_CONFIG}" = "tls.certresolver=letsencrypt" ]; then
|
||||
add_arg "--certificatesResolvers.letsencrypt.acme.storage=/certs/acme.json"
|
||||
add_arg "--certificatesResolvers.letsencrypt.acme.httpChallenge.entryPoint=http"
|
||||
add_arg "--certificatesResolvers.letsencrypt.acme.caserver=${TRAEFIK_ACME_CASERVER:-https://acme-v02.api.letsencrypt.org/directory}"
|
||||
|
||||
# Add proxy configuration if SOCKS_PROXY is set
|
||||
if [ -n "${SOCKS_PROXY}" ]; then
|
||||
echo "Configuring Traefik ACME with SOCKS proxy: ${SOCKS_PROXY}"
|
||||
# Note: Go's http.Client respects HTTP_PROXY env vars internally
|
||||
# We'll set it via environment for the subprocess
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add local certificate configuration if enabled
|
||||
|
||||
17
debug_mrp_mix.py
Normal file
17
debug_mrp_mix.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from datetime import datetime
|
||||
import traceback
|
||||
|
||||
Mix = self.env['mrp.lot.mix']
|
||||
mix_rec = Mix.search([('state', '=', 'draft')], order='id desc', limit=1)
|
||||
|
||||
if not mix_rec:
|
||||
print("No draft mrp.lot.mix record found.")
|
||||
else:
|
||||
print(f"Found draft mix record: ID={mix_rec.id}, Name={mix_rec.name}")
|
||||
try:
|
||||
print("Calling action_confirm_mix()...")
|
||||
mix_rec.action_confirm_mix()
|
||||
print("Success!")
|
||||
except Exception:
|
||||
print("Error caught during action_confirm_mix():")
|
||||
traceback.print_exc()
|
||||
@@ -11,6 +11,10 @@ services:
|
||||
- "TRAEFIK_ACME_CASERVER=${TRAEFIK_ACME_CASERVER:-https://acme-v02.api.letsencrypt.org/directory}"
|
||||
- "TRAEFIK_LOG_LEVEL=${TRAEFIK_LOG_LEVEL:-ERROR}"
|
||||
- "TRAEFIK_ACCESS_LOG=${TRAEFIK_ACCESS_LOG:-false}"
|
||||
- "SOCKS_PROXY=${SOCKS_PROXY}"
|
||||
- "HTTP_PROXY=${HTTP_PROXY}"
|
||||
- "HTTPS_PROXY=${HTTPS_PROXY}"
|
||||
- "NO_PROXY=${NO_PROXY:-localhost,127.0.0.1,172.16.0.0/12,10.0.0.0/8}"
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user