|
| 1 | +# CCSync nginx reverse proxy configuration |
| 2 | +# For production deployment with SSL (Let's Encrypt) |
| 3 | +# |
| 4 | +# Prerequisites: |
| 5 | +# 1. Install nginx: apt install nginx |
| 6 | +# 2. Install certbot: apt install certbot python3-certbot-nginx |
| 7 | +# 3. Obtain certificate: certbot certonly --standalone -d your-domain.com |
| 8 | +# 4. Copy this file to /etc/nginx/sites-available/ccsync |
| 9 | +# 5. Create symlink: ln -s /etc/nginx/sites-available/ccsync /etc/nginx/sites-enabled/ |
| 10 | +# 6. Remove default: rm /etc/nginx/sites-enabled/default |
| 11 | +# 7. Test config: nginx -t |
| 12 | +# 8. Reload nginx: systemctl reload nginx |
| 13 | +# |
| 14 | +# Note: Update docker-compose.yml to bind ports to localhost only: |
| 15 | +# frontend: "127.0.0.1:3000:80" |
| 16 | +# backend: "127.0.0.1:8000:8000" |
| 17 | +# syncserver: "127.0.0.1:8081:8080" |
| 18 | + |
| 19 | +# Redirect HTTP to HTTPS |
| 20 | +server { |
| 21 | + listen 80; |
| 22 | + listen [::]:80; |
| 23 | + server_name your-domain.com; |
| 24 | + |
| 25 | + location / { |
| 26 | + return 301 https://$server_name$request_uri; |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +# Main HTTPS server |
| 31 | +server { |
| 32 | + listen 443 ssl http2; |
| 33 | + listen [::]:443 ssl http2; |
| 34 | + server_name your-domain.com; |
| 35 | + |
| 36 | + # SSL certificates (update paths for your domain) |
| 37 | + ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; |
| 38 | + ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; |
| 39 | + |
| 40 | + # SSL configuration |
| 41 | + ssl_protocols TLSv1.2 TLSv1.3; |
| 42 | + ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384; |
| 43 | + ssl_prefer_server_ciphers off; |
| 44 | + ssl_session_cache shared:SSL:10m; |
| 45 | + ssl_session_timeout 1d; |
| 46 | + |
| 47 | + # Backend API routes |
| 48 | + location /auth/ { |
| 49 | + proxy_pass http://127.0.0.1:8000; |
| 50 | + proxy_http_version 1.1; |
| 51 | + proxy_set_header Host $host; |
| 52 | + proxy_set_header X-Real-IP $remote_addr; |
| 53 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 54 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 55 | + } |
| 56 | + |
| 57 | + location /api/ { |
| 58 | + proxy_pass http://127.0.0.1:8000; |
| 59 | + proxy_http_version 1.1; |
| 60 | + proxy_set_header Host $host; |
| 61 | + proxy_set_header X-Real-IP $remote_addr; |
| 62 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 63 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 64 | + } |
| 65 | + |
| 66 | + location /tasks { |
| 67 | + proxy_pass http://127.0.0.1:8000; |
| 68 | + proxy_http_version 1.1; |
| 69 | + proxy_set_header Host $host; |
| 70 | + proxy_set_header X-Real-IP $remote_addr; |
| 71 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 72 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 73 | + } |
| 74 | + |
| 75 | + location /add-task { |
| 76 | + proxy_pass http://127.0.0.1:8000; |
| 77 | + proxy_http_version 1.1; |
| 78 | + proxy_set_header Host $host; |
| 79 | + proxy_set_header X-Real-IP $remote_addr; |
| 80 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 81 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 82 | + } |
| 83 | + |
| 84 | + location /edit-task { |
| 85 | + proxy_pass http://127.0.0.1:8000; |
| 86 | + proxy_http_version 1.1; |
| 87 | + proxy_set_header Host $host; |
| 88 | + proxy_set_header X-Real-IP $remote_addr; |
| 89 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 90 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 91 | + } |
| 92 | + |
| 93 | + location /modify-task { |
| 94 | + proxy_pass http://127.0.0.1:8000; |
| 95 | + proxy_http_version 1.1; |
| 96 | + proxy_set_header Host $host; |
| 97 | + proxy_set_header X-Real-IP $remote_addr; |
| 98 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 99 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 100 | + } |
| 101 | + |
| 102 | + location /complete-task { |
| 103 | + proxy_pass http://127.0.0.1:8000; |
| 104 | + proxy_http_version 1.1; |
| 105 | + proxy_set_header Host $host; |
| 106 | + proxy_set_header X-Real-IP $remote_addr; |
| 107 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 108 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 109 | + } |
| 110 | + |
| 111 | + location /complete-tasks { |
| 112 | + proxy_pass http://127.0.0.1:8000; |
| 113 | + proxy_http_version 1.1; |
| 114 | + proxy_set_header Host $host; |
| 115 | + proxy_set_header X-Real-IP $remote_addr; |
| 116 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 117 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 118 | + } |
| 119 | + |
| 120 | + location /delete-task { |
| 121 | + proxy_pass http://127.0.0.1:8000; |
| 122 | + proxy_http_version 1.1; |
| 123 | + proxy_set_header Host $host; |
| 124 | + proxy_set_header X-Real-IP $remote_addr; |
| 125 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 126 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 127 | + } |
| 128 | + |
| 129 | + location /delete-tasks { |
| 130 | + proxy_pass http://127.0.0.1:8000; |
| 131 | + proxy_http_version 1.1; |
| 132 | + proxy_set_header Host $host; |
| 133 | + proxy_set_header X-Real-IP $remote_addr; |
| 134 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 135 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 136 | + } |
| 137 | + |
| 138 | + location /sync/ { |
| 139 | + proxy_pass http://127.0.0.1:8000; |
| 140 | + proxy_http_version 1.1; |
| 141 | + proxy_set_header Host $host; |
| 142 | + proxy_set_header X-Real-IP $remote_addr; |
| 143 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 144 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 145 | + } |
| 146 | + |
| 147 | + location /health { |
| 148 | + proxy_pass http://127.0.0.1:8000; |
| 149 | + proxy_http_version 1.1; |
| 150 | + proxy_set_header Host $host; |
| 151 | + proxy_set_header X-Real-IP $remote_addr; |
| 152 | + } |
| 153 | + |
| 154 | + location /docs { |
| 155 | + proxy_pass http://127.0.0.1:8000; |
| 156 | + proxy_http_version 1.1; |
| 157 | + proxy_set_header Host $host; |
| 158 | + proxy_set_header X-Real-IP $remote_addr; |
| 159 | + } |
| 160 | + |
| 161 | + # WebSocket support |
| 162 | + location /ws { |
| 163 | + proxy_pass http://127.0.0.1:8000; |
| 164 | + proxy_http_version 1.1; |
| 165 | + proxy_set_header Upgrade $http_upgrade; |
| 166 | + proxy_set_header Connection "upgrade"; |
| 167 | + proxy_set_header Host $host; |
| 168 | + proxy_set_header X-Real-IP $remote_addr; |
| 169 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 170 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 171 | + proxy_read_timeout 86400; |
| 172 | + } |
| 173 | + |
| 174 | + # Frontend (default) |
| 175 | + location / { |
| 176 | + proxy_pass http://127.0.0.1:3000; |
| 177 | + proxy_http_version 1.1; |
| 178 | + proxy_set_header Host $host; |
| 179 | + proxy_set_header X-Real-IP $remote_addr; |
| 180 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 181 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 182 | + } |
| 183 | +} |
| 184 | + |
| 185 | +# Taskchampion sync server (port 8080 with SSL) |
| 186 | +server { |
| 187 | + listen 8080 ssl http2; |
| 188 | + listen [::]:8080 ssl http2; |
| 189 | + server_name your-domain.com; |
| 190 | + |
| 191 | + ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; |
| 192 | + ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; |
| 193 | + ssl_protocols TLSv1.2 TLSv1.3; |
| 194 | + |
| 195 | + location / { |
| 196 | + proxy_pass http://127.0.0.1:8081; |
| 197 | + proxy_http_version 1.1; |
| 198 | + proxy_set_header Host $host; |
| 199 | + proxy_set_header X-Real-IP $remote_addr; |
| 200 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 201 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 202 | + } |
| 203 | +} |
0 commit comments