Why is the ssl_session_id being regenerated for some requests and reused for others in nginx?

I have containerized and deployed my angular app to nginx. I want to send a Content-Security-Policy header with a nonce. I am using $ssl_session_id for the nonce from nginx.

I am able to pass the nonce to the angular app and use it. But the issue I noticed is that for the ssl_session_id of each of the subrequests within the index.html, some are using a seperate $ssl_session_id and some are using the same $ssl_session_id as index.html

Thus the nonce set in the meta tag of the index.html is not matching with the nonce in the Content-Security-Policy header of some subrequests.

The expectation is that the nonce must be regenerated only everytime the index.html is served i.e everytime the angular app is reloaded and not for every subrequest within the index.html.

Below is the nginx.conf I am using right now

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>server{
listen 0.0.0.0:5443 ssl;
server_name innocent.csrfexample.com;
ssl_certificate /etc/nginx/secureAngularExample.crt;
ssl_certificate_key /etc/nginx/secureAngularExample.key;
default_type application/octet-stream;
error_log /var/log/nginx/error.log debug;
set $cspNonce $ssl_session_id;
sub_filter_once off;
sub_filter_types *;
sub_filter NGINX_CSP_NONCE $cspNonce;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
client_max_body_size 256M;
add_header 'Content-Security-Policy' "default-src 'self'; script-src 'self' 'nonce-$cspNonce'; style-src 'self' 'nonce-$cspNonce' always";
root /usr/share/nginx/html;
location /assets/ {
#assets within the root
autoindex on;
}
location / {
# matches any path within the root
try_files $uri $uri/index.html /index.html =404;
}
error_page 404 /index.html;
}
</code>
<code>server{ listen 0.0.0.0:5443 ssl; server_name innocent.csrfexample.com; ssl_certificate /etc/nginx/secureAngularExample.crt; ssl_certificate_key /etc/nginx/secureAngularExample.key; default_type application/octet-stream; error_log /var/log/nginx/error.log debug; set $cspNonce $ssl_session_id; sub_filter_once off; sub_filter_types *; sub_filter NGINX_CSP_NONCE $cspNonce; gzip on; gzip_comp_level 6; gzip_vary on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_buffers 16 8k; client_max_body_size 256M; add_header 'Content-Security-Policy' "default-src 'self'; script-src 'self' 'nonce-$cspNonce'; style-src 'self' 'nonce-$cspNonce' always"; root /usr/share/nginx/html; location /assets/ { #assets within the root autoindex on; } location / { # matches any path within the root try_files $uri $uri/index.html /index.html =404; } error_page 404 /index.html; } </code>
server{
    listen 0.0.0.0:5443 ssl;
    server_name innocent.csrfexample.com;
    ssl_certificate     /etc/nginx/secureAngularExample.crt;
    ssl_certificate_key /etc/nginx/secureAngularExample.key;
    default_type application/octet-stream;
    error_log /var/log/nginx/error.log debug;

set $cspNonce $ssl_session_id;
sub_filter_once off;
sub_filter_types *;
sub_filter NGINX_CSP_NONCE $cspNonce;

    gzip                    on;
    gzip_comp_level         6;
    gzip_vary               on;
    gzip_min_length         1000;
    gzip_proxied            any;
    gzip_types              text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_buffers            16 8k;
    client_max_body_size    256M;



    add_header 'Content-Security-Policy' "default-src 'self'; script-src 'self' 'nonce-$cspNonce';   style-src 'self' 'nonce-$cspNonce' always";
   

    root /usr/share/nginx/html;



        location /assets/ {
         #assets within the root
         autoindex on;
        }


        location / {
        # matches any path within the root
        try_files $uri $uri/index.html /index.html =404;

        }

        
        error_page  404              /index.html;


    }

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật