āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/clerk/clerk-docs/guides/development/deployment/behind-a-proxy ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
When deploying a Clerk app behind a proxy, you must forward two headers:
X-Forwarded-Host - The host of the request.X-Forwarded-Proto - The protocol of the request.Here are some common platforms and servers that require header proxying:
nginx configuration exampleThe following can be added to your nginx configuration to forward the headers to your application.
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
To test if the headers are forwarded correctly, you can console log them to check what their values are. They are available on the request object.
export default clerkMiddleware(
(auth, req) => {
console.log('=========================')
console.log('Request Headers')
console.log('x-forwarded-host', req.headers.get('x-forwarded-host'))
console.log('x-forwarded-proto', req.headers.get('x-forwarded-proto'))
console.log('=========================')
},
{ debug: debugStatus },
)
The X-Forwarded-Host header should return the same domain as the one you configured on the Domains page in the Clerk Dashboard. The X-Forwarded-Proto header should return https as Clerk requires this value to be https for production instances.
Here is an example result:
=========================
Request Headers
x-forwarded-host example.com
x-forwarded-proto https
=========================
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā