You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/16-websocket.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@
3
3
4
4
AdminForth provide own build-in websocket interface which allows to stream some data to frontend from backend.
5
5
6
+
If in production you run through a reverse proxy such as Nginx, ensure websocket upgrade is enabled on the `/afws` path under your AdminForth base URL, otherwise websocket will not work. See [Deploy in Docker > Nginx version](/docs/tutorial/deploy#nginx-version).
7
+
6
8
In two words, to subscribe to a topic from any frontend component you need to do next
If you want to deploy your AdminForth application to a sub-folder like `https://mydomain.com/admin` you
116
116
should do the following:
117
117
118
-
1) Open `index.ts` file and change `ADMIN_BASE_URL`constant to your subpath:
118
+
1) Open `index.ts` file and set the same subpath in `ADMIN_BASE_URL`and `baseUrl`:
119
119
120
120
```ts title='./index.ts'
121
121
//diff-remove
122
122
const ADMIN_BASE_URL ='';
123
123
//diff-add
124
124
const ADMIN_BASE_URL ='/admin/';
125
+
126
+
exportconst admin =newAdminForth({
127
+
baseUrl: ADMIN_BASE_URL,
128
+
...
129
+
});
125
130
```
126
131
127
132
2) Open `compose.yml` file and change `traefik.http.routers.adminforth.rule` to your subpath:
@@ -141,11 +146,18 @@ Now you can access your AdminForth application by going to `https://mydomain.com
141
146
142
147
If you want to automate the deployment process with CI follow [our docker - traefik guide](https://devforth.io/blog/onlogs-open-source-simplified-web-logs-viewer-for-dockers/)
143
148
144
-
# Nginx version
149
+
## Nginx version
145
150
146
-
If you are using Nginx instead of traefik, here is siple proxy pass config:
151
+
If you are using Nginx instead of traefik, proxy both regular HTTP traffic and AdminForth websocket endpoint.
147
152
148
-
```
153
+
AdminForth websocket always uses `<baseUrl>/afws`, where `<baseUrl>` is the same value you pass to `baseUrl: ADMIN_BASE_URL` in `index.ts`.
154
+
155
+
- If `ADMIN_BASE_URL = ''`, use `/afws`.
156
+
- If `ADMIN_BASE_URL = '/admin/'`, use `/admin/afws`.
157
+
158
+
For root deployment, the config can look like this:
If you deploy AdminForth under a subpath, use the same prefix in Nginx locations. For example, when `ADMIN_BASE_URL = '/admin/'`, the websocket path becomes `/admin/afws`:
0 commit comments