@@ -20,35 +20,60 @@ This proxy works both in development and in production, for example when deployi
20
20
React, NodeJS, Java, PHP, ... app to a server / the cloud or when developing it locally
21
21
on your machine.
22
22
23
+ The first argument ` application-url ` points to the location of your application. The Ory Proxy
24
+ will pass all traffic through to this URL.
25
+
26
+ $ ory proxy --project <your-project-slug> https://www.example.org
27
+ $ ORY_PROJECT_SLUG=<your-project-slug> ory proxy http://localhost:3000
28
+
29
+ ### Connecting to Ory
30
+
23
31
Before you start, you need to have a running Ory Cloud project. You can create one with the following command:
24
32
25
33
$ ory create project --name "Command Line Project"
26
34
27
- Pass the project's slug as a flag to the tunnel command:
35
+ Pass the project's slug as a flag to the proxy command:
28
36
29
37
$ ory proxy --project <your-project-slug> ...
30
38
$ ORY_PROJECT_SLUG=<your-project-slug> ory proxy ...
31
39
32
- The first argument ` app-url ` points to the location of your application. If you are
33
- running the proxy and your app on the same host, this could be localhost.
40
+ ### Developing Locally
41
+
42
+ When developing locally we recommend to use the ` --dev ` flag, which uses a lax security setting:
43
+
44
+ $ ory proxy --dev \
45
+ --project <your-project-slug> \
46
+ http://localhost:3000
34
47
35
- The second argument ` [publish-url] ` is optional. It refers to the public URL of your
36
- application (e.g. https://www.example.org ).
48
+ The first argument ` application-url ` points to the location of your application. If you are
49
+ running the proxy and your app on the same host, this could be localhost. All traffic arriving at the
50
+ Ory Proxy will be passed through to this URL.
51
+
52
+ The second argument ` [publish-url] ` is optional and only needed when going to production.
53
+ It refers to the public URL of your application (e.g. https://www.example.org ).
37
54
38
55
If ` [publish-url] ` is not set, it will default to the default
39
56
host and port this proxy listens on:
40
57
41
58
http://localhost:4000
42
59
60
+ ### Running on a Server
61
+
62
+ To go to production set up a custom domain (CNAME) for Ory. If you can not set up a custom
63
+ domain - for example because you are developing a staging environment - using the Ory Proxy is an alternative.
64
+
43
65
You must set the ` [publish-url] ` if you are not using the Ory Proxy in locally or in
44
66
development:
45
67
46
- $ ory proxy --project <your-project-slug> \
68
+ $ ory proxy \
69
+ --project <your-project-slug> \
47
70
http://localhost:3000 \
48
71
https://example.org
49
72
50
73
Please note that you can not set a path in the ` [publish-url] ` !
51
74
75
+ ### Ports
76
+
52
77
Per default, the proxy listens on port 4000. If you want to listen on another port, use the
53
78
port flag:
54
79
@@ -62,15 +87,21 @@ If your public URL is available on a non-standard HTTP/HTTPS port, you can set t
62
87
http://localhost:3000 \
63
88
https://example.org:1234
64
89
90
+ ### Multiple Domains
91
+
65
92
If this proxy runs on a subdomain, and you want Ory's cookies (e.g. the session cookie) to
66
93
be available on all of your domain, you can use the following CLI flag to customize the cookie
67
- domain:
94
+ domain. You will also need to allow your subdomains in the CORS headers :
68
95
69
96
$ ory proxy --project <your-project-slug> \
70
97
--cookie-domain example.org \
98
+ --allowed-cors-origins https://www.example.org \
99
+ --allowed-cors-origins https://api.example.org \
71
100
http://127.0.0.1:3000 \
72
101
https://ory.example.org
73
102
103
+ ### Redirects
104
+
74
105
Per default all default redirects will go to to ` [publish-url] ` . You can change this behavior using
75
106
the ` --default-redirect-url ` flag:
76
107
@@ -82,12 +113,14 @@ the `--default-redirect-url` flag:
82
113
Now, all redirects happening e.g. after login will point to ` /welcome ` instead of ` / ` unless you
83
114
have specified custom redirects in your Ory configuration or in the flow's ` ?return_to= ` query parameter.
84
115
116
+ ### JSON Web Token
117
+
85
118
If the request is not authenticated, the HTTP Authorization Header will be empty:
86
119
87
120
GET / HTTP/1.1
88
121
Host: localhost:3000
89
122
90
- If the request was authenticated, a JSON Web Token will be sent in the HTTP Authorization Header containing the
123
+ If the request was authenticated, a JSON Web Token can be sent in the HTTP Authorization Header containing the
91
124
Ory Session:
92
125
93
126
GET / HTTP/1.1
@@ -123,19 +156,33 @@ An example payload of the JSON Web Token is:
123
156
124
157
125
158
```
126
- ory proxy app-url [publish-url] [flags]
159
+ ory proxy application-url [publish-url] [flags]
160
+ ```
161
+
162
+ ### Examples
163
+
164
+ ```
165
+ ory proxy http://localhost:3000 --dev
166
+ ory proxy http://localhost:3000 https://app.example.com \
167
+ --allowed-cors-origins https://www.example.org \
168
+ --allowed-cors-origins https://api.example.org \
169
+ --allowed-cors-origins https://www.another-app.com
170
+
127
171
```
128
172
129
173
### Options
130
174
131
175
```
132
- --cookie-domain string Set a dedicated cookie domain.
133
- --default-redirect-url string Set the URL to redirect to per default after e.g. login or account creation.
134
- -h, --help help for proxy
135
- --no-jwt Do not create a JWT from the Ory Kratos Session. Useful if you need fast start up times of the Ory Proxy.
136
- --open Open the browser when the proxy starts.
137
- --port int The port the proxy should listen on. (default 4000)
138
- --project string The slug of your Ory Cloud Project.
176
+ --allowed-cors-origins strings A list of allowed CORS origins. Wildcards are allowed.
177
+ --cookie-domain string Set a dedicated cookie domain.
178
+ --debug Use this flag to debug, for example, CORS requests.
179
+ --default-redirect-url string Set the URL to redirect to per default after e.g. login or account creation.
180
+ --dev Use this flag when developing locally.
181
+ -h, --help help for proxy
182
+ --no-jwt Do not create a JWT from the Ory Kratos Session. Useful if you need fast start up times of the Ory Proxy.
183
+ --open Open the browser when the proxy starts.
184
+ --port int The port the proxy should listen on. (default 4000)
185
+ --project string The slug of your Ory Cloud Project.
139
186
```
140
187
141
188
### SEE ALSO
0 commit comments