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

#110 updating ingress config to fix websocket connectivity. #114

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ingress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ EXPOSE 8080
ARG NGINX_HOST="localhost"
ENV NGINX_HOST=$NGINX_HOST

# This is a workaround for the dollar sign in the envsubst command
ARG DOLLAR="$"
ENV DOLLAR=$DOLLAR

COPY nginx.traderx.conf.template /etc/nginx/conf.d/nginx.traderx.conf.template

RUN envsubst < /etc/nginx/conf.d/nginx.traderx.conf.template > /etc/nginx/conf.d/default.conf
93 changes: 61 additions & 32 deletions ingress/nginx.traderx.conf.template
Original file line number Diff line number Diff line change
@@ -1,32 +1,61 @@
server {
listen 8080;
server_name $NGINX_HOST;

location /db-web/ {
proxy_pass http://database:18084/;
}
location /reference-data/ {
proxy_pass http://reference-data:18085/;
}
location /trade-feed/ {
proxy_pass http://trade-feed:18086/;
}
location /people-service/ {
proxy_pass http://people-service:18089/;
}
location /account-service/ {
proxy_pass http://account-service:18088/;
}
location /position-service/ {
proxy_pass http://position-service:18090/;
}
location /trade-service/ {
proxy_pass http://trade-service:18092/;
}
location /trade-processor/ {
proxy_pass http://trade-processor:18091/;
}
location / {
proxy_pass http://web-front-end-angular:18093/;
}
}
server {
listen 8080;
server_name $NGINX_HOST;

location /db-web/ {
proxy_pass http://database:18084/;
}
location /reference-data/ {
proxy_pass http://reference-data:18085/;
}

location /ng-cli-ws {
DovOps marked this conversation as resolved.
Show resolved Hide resolved
proxy_pass http://web-front-end-angular:18093/ng-cli-ws;
proxy_http_version 1.1;
proxy_set_header Upgrade ${DOLLAR}http_upgrade;
proxy_set_header Connection "upgrade";
}

location /trade-feed/ {
proxy_set_header X-Forwarded-For ${DOLLAR}proxy_add_x_forwarded_for;
proxy_set_header Host ${DOLLAR}http_host;

proxy_pass http://trade-feed:18086/;

proxy_http_version 1.1;
proxy_set_header Upgrade ${DOLLAR}http_upgrade;
proxy_set_header Connection "upgrade";

}

location /socket.io/ {
proxy_set_header X-Forwarded-For ${DOLLAR}proxy_add_x_forwarded_for;
proxy_set_header Host ${DOLLAR}http_host;

proxy_pass http://trade-feed:18086/socket.io/;

proxy_http_version 1.1;
proxy_set_header Upgrade ${DOLLAR}http_upgrade;
proxy_set_header Connection "upgrade";

}

location /people-service/ {
proxy_pass http://people-service:18089/;
}
location /account-service/ {
proxy_pass http://account-service:18088/;
}
location /position-service/ {
proxy_pass http://position-service:18090/;
}
location /trade-service/ {
proxy_pass http://trade-service:18092/;
}
location /trade-processor/ {
proxy_pass http://trade-processor:18091/;
}
location / {
proxy_pass http://web-front-end-angular:18093/;
}
}
3 changes: 2 additions & 1 deletion trade-feed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const http = require('http').createServer(app);

const io = new sockio.Server(http, {
cors: {
origin: "*"
origin: "*",
methods: ["GET", "POST"]
}
});
const port = process.env.TRADE_FEED_PORT || 18086;
Expand Down
2 changes: 1 addition & 1 deletion trade-feed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.2",
"socket.io": "^4.7.2",
"socket.io": "^4.7.4",
"winston": "^3.11.0"
}
}
6 changes: 4 additions & 2 deletions web-front-end/angular/main/app/service/trade-feed.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export class TradeFeedService {
this.connect();
}

private connect(forceNew = false) {
this.socket = io(environment.tradeFeedUrl, { forceNew });
private connect() {
// create socketio client with long polling only
this.socket = io(environment.tradeFeedUrl);

this.socket.on("connect", this.onConnect);
this.socket.on("disconnect", this.onDisconnect);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export const environment = {
tradesUrl: 'https://' + window.location.hostname + '/trade-service/trade/',
positionsUrl: 'https://' + window.location.hostname + '/position-service',
peopleUrl: 'https://' + window.location.hostname + '/people-service/people',
tradeFeedUrl: 'https://' + window.location.hostname + '/trade-feed/'
tradeFeedUrl: 'https://' + window.location.hostname
};
2 changes: 1 addition & 1 deletion web-front-end/angular/main/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const environment = {
tradesUrl: 'https://' + window.location.hostname + '/trade-service/trade/',
positionsUrl: 'https://' + window.location.hostname + '/position-service',
peopleUrl: 'https://' + window.location.hostname + '/people-service/people',
tradeFeedUrl: 'https://' + window.location.hostname + '/trade-feed/'
tradeFeedUrl: 'https://' + window.location.hostname
};

/*
Expand Down