Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added doc for for web server deployment #1813

Merged
merged 7 commits into from
Dec 21, 2024

Conversation

royanger
Copy link
Member

@royanger royanger commented Dec 16, 2024

Explanation:

This creates a new Deployment doc covering the two headers that must be forwarded from the server/container to the application for Clerk to work correctly.

This PR:

Lists the headers, has a basic nginx example and covers how to test that the config is correct.

Checklist

  • I have clicked on "Files changed" and performed a thorough self-review
  • I have added the "deploy-preview" label and added the preview link(s) to this PR description
  • All existing checks pass

Copy link

Hey, here’s your docs preview: https://clerk.com/docs/pr/1813

@royanger royanger marked this pull request as ready for review December 16, 2024 19:32
@royanger royanger requested a review from a team as a code owner December 16, 2024 19:32
@braden-clerk
Copy link
Contributor

Would "Deploying behind a proxy" be a better way to frame this?

@royanger
Copy link
Member Author

Would "Deploying behind a proxy" be a better way to frame this?

That might be. I think its more accurate, but I am wondering if the people who will need it might not realize they are using a proxy. eg, Caddy calls itself a web server on its main page. nginx says web server and reverse proxy. Also not everyone realizes that Docker is proxying external traffic to internal services.

My gut feeling is to leave it as if, but make sure that the doc itself mentions proxy and reverse proxy for searches.

@royanger royanger changed the title feat: Added for for web server deployment feat: Added doc for for web server deployment Dec 17, 2024
@JacobMGEvans
Copy link
Contributor

I think the more explicit/specific the title might help people coming to us with these issues. I tend to agree with Roy in this case, the type of people that I tend to help that need a doc like this are not super familiar with the infrastructure they are using or understand what it is doing fully.

@jescalan
Copy link
Contributor

agreed with braden here

@royanger
Copy link
Member Author

I will get a new version up tomorrow. I'll make sure the content should be good for searches.

description: Learn how to deploy a Clerk app to a web server using proxies and reverse proxies like nginx or Caddy, or using Docker
---

When deploying a Clerk app beind a proxy, you may need to proxy two headers for Clerk to work correctly. The two headers that you must forward are:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first sentence says they "may need to" proxy the two headers. the second sentence says they "must" forward the headers.

is it required, or is it not required?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use more assured its required tense, I think its safe to assume it needed in nearly if not all network configs.


## How to test if the headers are forwarded correctly:

You can console log the `X-forwarded-host` and `X-forwarded-proto` to check what the value is. The following example is for Next.js.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should the values be, so that the user knows that the forwarding worked?

Copy link
Contributor

@JacobMGEvans JacobMGEvans Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • X-Forwarded-Host: The original host that the client requested, like if your public domain is example.com, then X-Forwarded-Host should appear as example.com

  • X-Forwarded-Proto: The original protocol used by the client. If your site is served over HTTPS, then X-Forwarded-Proto should appear as https... Clerk requires HTTPS in Prod so it needs to be HTTPS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example expected output from the console log, assuming that the application's production domain is clerk.com below. I'll add this to the PR now.

=========================
Request Headers
x-forwarded-host clerk.com
x-forwarded-proto https
=========================

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in ed19a2d

Copy link
Member

@alexisintech alexisintech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've posted my docs review, lmk what you think! if you want to change it, feel free, or if you like it, feel free to merge! 😸💖

@royanger royanger merged commit 3330da2 into main Dec 21, 2024
4 checks passed
@royanger royanger deleted the roy/add-deployment-section-for-web-servers branch December 21, 2024 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants