for my Webapp (Angular App) we are using NGNIX as web server. I have a task where I need to make sure all assets/images are loaded over HTTPS.
In the Browser Dev tools, I see the request is sent over HTTPS. However, the response location header is coming back as an HTTP URL (see screenshot below).
Here are the current NGNIX Configs:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache';
if_modified_since off;
expires off;
etag off;
# Enforce HSTS
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# Disable iFrames
add_header x-frame-options "SAMEORIGIN" always;
# detect and reject CRLF
if ($request_uri ~* "%0A|%0D" ) {
return 400;
}
# Fallback to default language if no preference defined by browser
if ($accept_language ~ "^$") {
set $accept_language "de";
}
# Redirect "/" to Angular app in browser's preferred language
rewrite ^/$ /$accept_language permanent;
if ($uri !~ ^/(en-US|de)) {
return 301 /$accept_language$uri$args;
}
# Everything under the Angular app is always redirected to Angular in the correct language
location ~ ^/(en-US|de) {
try_files $uri$args $uri$args/ /$1/index.html;
# Add security headers from separate file
# include /etc/nginx/security-headers.conf;
}
location /health {
access_log off;
return 200;
add_header Content-Type text/plain;
# Enforce HSTS
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}
}
Any help is highly appreciated. Thanks