Skip to content

Commit d4b0060

Browse files
committed
add docker + nginx config
1 parent 19b4191 commit d4b0060

6 files changed

Lines changed: 45 additions & 3 deletions

File tree

Back-end/.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
.git
33
.env
4-
dist
4+
dist
5+
.env.*

Back-end/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ coverage
55
logs
66
*.log
77
*.env
8+
.env.*
89
.DS_Store
910
.idea
1011
.vscode

Back-end/utils/features.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { getBase64, getSockets } from "../lib/helper.js";
66

77
const cookieOptions = {
88
maxAge: 15 * 24 * 60 * 60 * 1000,
9-
sameSite: "none",
9+
sameSite: "lax",
1010
httpOnly: true,
11-
secure: true,
11+
secure: process.env.NODE_ENV === "production" ? true : false, // Set secure to true for production
12+
1213
};
1314

1415
const connectDB = (uri) => {

Front-end/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ coverage
55
logs
66
*.log
77
*.env
8+
.env.*
89
.DS_Store
910
.idea
1011
.vscode

Front-end/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ FROM nginx:alpine
2424

2525
COPY --from=build /app/dist /usr/share/nginx/html
2626

27+
COPY nginx.conf /etc/nginx/conf.d/default.conf
28+
2729
EXPOSE 80
2830

2931
CMD ["nginx", "-g", "daemon off;"]

Front-end/nginx.conf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
map $http_upgrade $connection_upgrade {
2+
default upgrade;
3+
'' close;
4+
}
5+
6+
server {
7+
listen 80;
8+
9+
location / {
10+
root /usr/share/nginx/html;
11+
index index.html;
12+
try_files $uri $uri/ /index.html;
13+
}
14+
15+
location /api {
16+
proxy_pass http://mern-backend:3000;
17+
proxy_http_version 1.1;
18+
proxy_set_header Host $host;
19+
proxy_set_header X-Real-IP $remote_addr;
20+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21+
proxy_set_header Cookie $http_cookie;
22+
proxy_pass_header Set-Cookie;
23+
}
24+
25+
location /socket.io {
26+
proxy_pass http://mern-backend:3000;
27+
proxy_http_version 1.1;
28+
proxy_set_header Upgrade $http_upgrade;
29+
proxy_set_header Connection $connection_upgrade;
30+
proxy_set_header Host $host;
31+
proxy_set_header X-Real-IP $remote_addr;
32+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
33+
proxy_set_header Cookie $http_cookie;
34+
proxy_read_timeout 86400s;
35+
}
36+
}

0 commit comments

Comments
 (0)