nchan_access_control_allow_credentials
The nchan_access_control_allow_credentials directive controls whether to allow credentials to be included with cross-origin requests made through Nchan.
Description
The nchan_access_control_allow_credentials directive is a part of the Nginx module for Nchan, which implements a scalable pub/sub messaging system. This directive influences the behavior of Cross-Origin Resource Sharing (CORS) by determining if browsers are allowed to include credentials—such as cookies or HTTP authentication schemes—in cross-origin requests when using Nchan. When set to 'on', it allows client-side applications to include credentials in requests to the Nchan service, providing greater flexibility in web applications that require authentication and stateful interactions across different domains.
This directive can take a single argument: either 'on' or 'off'. Setting it to 'on' enables credential sharing, enabling scenarios where session data stored in cookies can be sent with cross-origin AJAX requests, which is critical for authenticated requests to function correctly across different domains. Such a configuration is beneficial when you need secure communication between a client and an Nchan server that exists on a different origin.
In contexts where this directive is applied—http, server, or location blocks—its effect can be scoped accordingly, allowing for robust control over the cross-origin requests. However, it is essential to make sure that your application and its backend servers are properly configured to handle credentials to avoid security vulnerabilities that arise from enabling CORS.
Config Example
location /pubsub {
nchan_access_control_allow_credentials on;
}Ensure that the Nginx server is also configured with proper CORS headers to avoid issues with browser restrictions.
Only enable this directive if you're comfortable with the security implications of sharing credentials across origins.