1. Caddy version (caddy version
): 1.13.1
2. How I run Caddy:
a. System environment:
Nomad
b. Command:
caddy.exe -conf ./caddy/Caddyfile.acceptance
caddy.exe -conf ./caddy/Caddyfile.production
c. Service/unit/compose file:
d. My complete Caddyfile or JSON config:
:2015 {
# Add plugins/directives
gzip
# Get Caddy to serve content from the dist folder as the root of the site
# So https://<server>/index.html would serve out of /<path>/dist/index.html, if it exists
root ./dist
# Docker containers must log to stdout in order for logs to be pulled in to ELK
log / stdout "{combined}"
# these are required for the nosniff header below as they are not served by vue
header /app.js {
Content-Type text/javascript
}
header /globals.js {
Content-Type text/javascript
}
header /analytics/digitalData.js {
Content-Type text/javascript
}
header / {
# remove the default "Server: Caddy" header for all requests
-Server
# enable HSTS
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# headers to get a better security rating
Content-Security-Policy "form-action 'self'; frame-ancestors 'self'; manifest-src 'self'; media-src 'self'; base-uri 'self'; object-src 'none'; worker-src 'none'; upgrade-insecure-requests;"
Cache-Control "no-cache"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "sameorigin"
}
# Create proxy for adobe analytics - Aceptance
proxy /adobeAssets https://assets.adobedtm.com/6279662c4fd9/5d31b06b6101/launch-c751d58c841b-development.min.js {
without /adobeAssets
header_upstream Content-Type application/javascript
header_downstream Content-Type application/javascript
}
# Create proxy for adobe analytics - Production
#proxy /adobeAssets https://assets.adobedtm.com/6279662c4fd9/5d31b06b6101/launch-a1d3d0a1b1cb.min.js {
# without /adobeAssets
# header_upstream Content-Type application/javascript
# header_downstream Content-Type application/javascript
#}
# Comment this in if you are using history mode for SPA routing
rewrite {
if {uri} not_has includes
if {uri} not_has /login
if {uri} not_has /logout
if {uri} not_has /signin
if {uri} not_has /adobeAssets
to {path} {path}.html /
}
}
3. The problem I’m having:
This is the index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1.0"
/>
<script type="application/javascript" src="<%= BASE_URL %>globals.js"></script>
<!-- Begin Analytics-->
<script type="application/javascript" src="<%= BASE_URL %>adobeAssets"></script>
<script type="application/javascript" src="<%= BASE_URL %>analytics/digitalData.js"></script>
<!-- End Analytics-->
<!--Noto Font-->
<link
href="https://fonts.googleapis.com/css?family=Noto+Sans&display=swap"
rel="stylesheet"
/>
<link rel="icon" href="<%= BASE_URL %>MLI-favicon.ico" />
<title>My website</title>
</head>
<body>
<noscript>
<strong
>We're sorry, but this site doesn't work properly without JavaScript
enabled. Please enable it to continue.
</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<script type="text/javascript">try{_satellite.pageBottom();}catch(e){}</script>
</body>
</html>
<%= BASE_URL %>adobeAssets tries to load Adobe Analytics .js file.
It uses the proxy from the caddy file to get to the actual file from https://assets.adobedtm.com/…
The file is different for Acceptance and Production. Using a proxy was a nice way to get to the correct file and it was working fine for months but not anymore. Now the request to https://myclientwebsite.com/adobeAssets returns “502 Bad Gateway”
The application is running in containers in Nomad and there is F5 load balancer in front of it. I suspect new iRule added to F5 is causing the problem but I am not sure.
4. Error messages and/or full log output:
“502 Bad Gateway”
5. What I already tried:
Running the application locally with the Acceptance caddy file does not have the problem. Only when it runs in Nomad it has the problem.
I have no control of F5 configuration. I would like to be able to load the correct .js file based on the environment. Is there a different way than using the proxy directive?