|
| 1 | +# Global configuration |
| 2 | +{ |
| 3 | + |
| 4 | + |
| 5 | + # Enable proxying from all servers by default. Otherwise, X-Forwarded-* headers will |
| 6 | + # be overwritten. |
| 7 | + # https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#defaults |
| 8 | + servers { |
| 9 | + trusted_proxies static 0.0.0.0/0 ::/0 |
| 10 | + } |
| 11 | + |
| 12 | + |
| 13 | +} |
| 14 | + |
| 15 | +# proxy directive snippet (with logging) to be used as follows: |
| 16 | +# |
| 17 | +# import proxy "containername:port" |
| 18 | +(proxy) { |
| 19 | + log { |
| 20 | + output stdout |
| 21 | + format filter { |
| 22 | + wrap json |
| 23 | + fields { |
| 24 | + common_log delete |
| 25 | + request>headers delete |
| 26 | + resp_headers delete |
| 27 | + tls delete |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + # This will compress requests that matches the default criteria set by Caddy. |
| 33 | + # see https://caddyserver.com/docs/caddyfile/directives/encode |
| 34 | + # for information about the defaults; i.e. how/when this will be applied. |
| 35 | + encode gzip |
| 36 | + |
| 37 | + reverse_proxy {args.0} { |
| 38 | + header_up X-Forwarded-Port 443 |
| 39 | + } |
| 40 | + |
| 41 | + |
| 42 | +} |
| 43 | + |
| 44 | +mfe-demo.phd.opencraft.hosting{$default_site_port}, preview.mfe-demo.phd.opencraft.hosting{$default_site_port} { |
| 45 | + @favicon_matcher { |
| 46 | + path_regexp ^/favicon.ico$ |
| 47 | + } |
| 48 | + rewrite @favicon_matcher /theming/asset/images/favicon.ico |
| 49 | + |
| 50 | + # Limit profile image upload size |
| 51 | + handle_path /api/profile_images/*/*/upload { |
| 52 | + request_body { |
| 53 | + max_size 1MB |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + import proxy "lms:8000" |
| 58 | + |
| 59 | + |
| 60 | + @mfe_authn { |
| 61 | + path /authn /authn/* |
| 62 | + } |
| 63 | + handle @mfe_authn { |
| 64 | + redir /authn /authn/ |
| 65 | + reverse_proxy mfe:8002 { |
| 66 | + header_up Host {host} |
| 67 | + } |
| 68 | + } |
| 69 | + @mfe_account { |
| 70 | + path /account /account/* |
| 71 | + } |
| 72 | + handle @mfe_account { |
| 73 | + redir /account /account/ |
| 74 | + handle /account/settings { |
| 75 | + reverse_proxy lms:8000 |
| 76 | + } |
| 77 | + handle /account/password { |
| 78 | + reverse_proxy lms:8000 |
| 79 | + } |
| 80 | + handle /account/finish_auth { |
| 81 | + reverse_proxy lms:8000 |
| 82 | + } |
| 83 | + reverse_proxy mfe:8002 { |
| 84 | + header_up Host {host} |
| 85 | + } |
| 86 | + } |
| 87 | + @mfe_communications { |
| 88 | + path /communications /communications/* |
| 89 | + } |
| 90 | + handle @mfe_communications { |
| 91 | + redir /communications /communications/ |
| 92 | + reverse_proxy mfe:8002 { |
| 93 | + header_up Host {host} |
| 94 | + } |
| 95 | + } |
| 96 | + @mfe_discussions { |
| 97 | + path /discussions /discussions/* |
| 98 | + } |
| 99 | + handle @mfe_discussions { |
| 100 | + redir /discussions /discussions/ |
| 101 | + reverse_proxy mfe:8002 { |
| 102 | + header_up Host {host} |
| 103 | + } |
| 104 | + } |
| 105 | + @mfe_gradebook { |
| 106 | + path /gradebook /gradebook/* |
| 107 | + } |
| 108 | + handle @mfe_gradebook { |
| 109 | + redir /gradebook /gradebook/ |
| 110 | + reverse_proxy mfe:8002 { |
| 111 | + header_up Host {host} |
| 112 | + } |
| 113 | + } |
| 114 | + @mfe_learner-dashboard { |
| 115 | + path /learner-dashboard /learner-dashboard/* |
| 116 | + } |
| 117 | + handle @mfe_learner-dashboard { |
| 118 | + redir /learner-dashboard /learner-dashboard/ |
| 119 | + reverse_proxy mfe:8002 { |
| 120 | + header_up Host {host} |
| 121 | + } |
| 122 | + } |
| 123 | + @mfe_learning { |
| 124 | + path /learning /learning/* |
| 125 | + } |
| 126 | + handle @mfe_learning { |
| 127 | + redir /learning /learning/ |
| 128 | + reverse_proxy mfe:8002 { |
| 129 | + header_up Host {host} |
| 130 | + } |
| 131 | + } |
| 132 | + @mfe_ora-grading { |
| 133 | + path /ora-grading /ora-grading/* |
| 134 | + } |
| 135 | + handle @mfe_ora-grading { |
| 136 | + redir /ora-grading /ora-grading/ |
| 137 | + reverse_proxy mfe:8002 { |
| 138 | + header_up Host {host} |
| 139 | + } |
| 140 | + } |
| 141 | + @mfe_profile { |
| 142 | + path /profile /profile/* |
| 143 | + } |
| 144 | + handle @mfe_profile { |
| 145 | + redir /profile /profile/ |
| 146 | + reverse_proxy mfe:8002 { |
| 147 | + header_up Host {host} |
| 148 | + } |
| 149 | + } |
| 150 | + |
| 151 | + |
| 152 | + handle_path /* { |
| 153 | + request_body { |
| 154 | + max_size 4MB |
| 155 | + } |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +studio.mfe-demo.phd.opencraft.hosting{$default_site_port} { |
| 160 | + @favicon_matcher { |
| 161 | + path_regexp ^/favicon.ico$ |
| 162 | + } |
| 163 | + rewrite @favicon_matcher /theming/asset/images/favicon.ico |
| 164 | + |
| 165 | + import proxy "cms:8000" |
| 166 | + |
| 167 | + |
| 168 | + reverse_proxy /api/mfe_config/v1* lms:8000 { |
| 169 | + header_up Host mfe-demo.phd.opencraft.hosting |
| 170 | + } |
| 171 | + @authoring path_regexp authoring /course-authoring/(.*) |
| 172 | + redir @authoring /authoring/{re.authoring.1} permanent |
| 173 | + @mfe_authoring { |
| 174 | + path /authoring /authoring/* |
| 175 | + } |
| 176 | + handle @mfe_authoring { |
| 177 | + redir /authoring /authoring/ |
| 178 | + reverse_proxy mfe:8002 { |
| 179 | + header_up Host {host} |
| 180 | + } |
| 181 | + } |
| 182 | + |
| 183 | + |
| 184 | + handle_path /* { |
| 185 | + request_body { |
| 186 | + max_size 250MB |
| 187 | + } |
| 188 | + } |
| 189 | +} |
| 190 | + |
| 191 | + |
| 192 | +meilisearch.mfe-demo.phd.opencraft.hosting{$default_site_port} { |
| 193 | + import proxy "meilisearch:7700" |
| 194 | +} |
| 195 | + |
| 196 | + |
| 197 | +apps.mfe-demo.phd.opencraft.hosting{$default_site_port} { |
| 198 | + redir / https://mfe-demo.phd.opencraft.hosting |
| 199 | + request_body { |
| 200 | + max_size 2MB |
| 201 | + } |
| 202 | + import proxy "mfe:8002" |
| 203 | +} |
| 204 | +{$default_site_port} { |
| 205 | + @favicon_matcher { |
| 206 | + path_regexp ^/favicon.ico$ |
| 207 | + } |
| 208 | + rewrite @favicon_matcher /theming/asset/images/favicon.ico |
| 209 | + |
| 210 | + |
| 211 | +@mfe_authn { |
| 212 | + path /authn /authn/* |
| 213 | +} |
| 214 | +handle @mfe_authn { |
| 215 | + redir /authn /authn/ |
| 216 | + reverse_proxy mfe:8002 { |
| 217 | + header_up Host {host} |
| 218 | + } |
| 219 | +} |
| 220 | +@mfe_account { |
| 221 | + path /account /account/* |
| 222 | +} |
| 223 | +handle @mfe_account { |
| 224 | + redir /account /account/ |
| 225 | + handle /account/settings { |
| 226 | + reverse_proxy lms:8000 |
| 227 | + } |
| 228 | + handle /account/password { |
| 229 | + reverse_proxy lms:8000 |
| 230 | + } |
| 231 | + handle /account/finish_auth { |
| 232 | + reverse_proxy lms:8000 |
| 233 | + } |
| 234 | + reverse_proxy mfe:8002 { |
| 235 | + header_up Host {host} |
| 236 | + } |
| 237 | +} |
| 238 | +@mfe_communications { |
| 239 | + path /communications /communications/* |
| 240 | +} |
| 241 | +handle @mfe_communications { |
| 242 | + redir /communications /communications/ |
| 243 | + reverse_proxy mfe:8002 { |
| 244 | + header_up Host {host} |
| 245 | + } |
| 246 | +} |
| 247 | +@mfe_discussions { |
| 248 | + path /discussions /discussions/* |
| 249 | +} |
| 250 | +handle @mfe_discussions { |
| 251 | + redir /discussions /discussions/ |
| 252 | + reverse_proxy mfe:8002 { |
| 253 | + header_up Host {host} |
| 254 | + } |
| 255 | +} |
| 256 | +@mfe_gradebook { |
| 257 | + path /gradebook /gradebook/* |
| 258 | +} |
| 259 | +handle @mfe_gradebook { |
| 260 | + redir /gradebook /gradebook/ |
| 261 | + reverse_proxy mfe:8002 { |
| 262 | + header_up Host {host} |
| 263 | + } |
| 264 | +} |
| 265 | +@mfe_learner-dashboard { |
| 266 | + path /learner-dashboard /learner-dashboard/* |
| 267 | +} |
| 268 | +handle @mfe_learner-dashboard { |
| 269 | + redir /learner-dashboard /learner-dashboard/ |
| 270 | + reverse_proxy mfe:8002 { |
| 271 | + header_up Host {host} |
| 272 | + } |
| 273 | +} |
| 274 | +@mfe_learning { |
| 275 | + path /learning /learning/* |
| 276 | +} |
| 277 | +handle @mfe_learning { |
| 278 | + redir /learning /learning/ |
| 279 | + reverse_proxy mfe:8002 { |
| 280 | + header_up Host {host} |
| 281 | + } |
| 282 | +} |
| 283 | +@mfe_ora-grading { |
| 284 | + path /ora-grading /ora-grading/* |
| 285 | +} |
| 286 | +handle @mfe_ora-grading { |
| 287 | + redir /ora-grading /ora-grading/ |
| 288 | + reverse_proxy mfe:8002 { |
| 289 | + header_up Host {host} |
| 290 | + } |
| 291 | +} |
| 292 | +@mfe_profile { |
| 293 | + path /profile /profile/* |
| 294 | +} |
| 295 | +handle @mfe_profile { |
| 296 | + redir /profile /profile/ |
| 297 | + reverse_proxy mfe:8002 { |
| 298 | + header_up Host {host} |
| 299 | + } |
| 300 | +} |
| 301 | + |
| 302 | + # Limit profile image upload size |
| 303 | + request_body /api/profile_images/*/*/upload { |
| 304 | + max_size 1MB |
| 305 | + } |
| 306 | + request_body { |
| 307 | + max_size 4MB |
| 308 | + } |
| 309 | + import proxy "lms:8000" |
| 310 | + |
| 311 | + |
| 312 | + |
| 313 | +} |
| 314 | + |
0 commit comments