Fix nginx proxy port (3001), add nginx.conf to Dockerfile, add /ws proxy, fix WebSocketProvider for production URLs
This commit is contained in:
@@ -9,5 +9,6 @@ RUN npm run build
|
|||||||
# Production stage
|
# Production stage
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
+14
-1
@@ -12,7 +12,20 @@ server {
|
|||||||
|
|
||||||
# Proxy API requests to backend
|
# Proxy API requests to backend
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://backend:5000;
|
proxy_pass http://backend:3001;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Proxy WebSocket requests to backend
|
||||||
|
location /ws/ {
|
||||||
|
proxy_pass http://backend:3001;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ export class WebSocketProvider {
|
|||||||
provider: WebsocketProvider;
|
provider: WebsocketProvider;
|
||||||
|
|
||||||
constructor(doc: Y.Doc, projectId: string, jwtToken: string) {
|
constructor(doc: Y.Doc, projectId: string, jwtToken: string) {
|
||||||
const url = `ws://localhost:3001/project:${projectId}`;
|
const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
|
const url = `${proto}//${window.location.host}/ws/collab`;
|
||||||
this.provider = new WebsocketProvider(url, `project:${projectId}`, doc, {
|
this.provider = new WebsocketProvider(url, `project:${projectId}`, doc, {
|
||||||
params: { token: jwtToken }
|
params: { token: jwtToken }
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user