Skip to content

Commit a3eae90

Browse files
committed
Merge remote-tracking branch 'origin/nginx-initial-setup' into n9-api-gateway
2 parents 2733b84 + 6e587f5 commit a3eae90

File tree

4 files changed

+97
-3
lines changed

4 files changed

+97
-3
lines changed

nginx/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### So far local testing completed:
2+
3+
1. Run frontend/backend services (front 3000, qn 9090, user 3001)
4+
2. copy nginx.conf into ur local install location
5+
3. start nginx
6+
4. go to localhost and should hopefully see the site
7+
8+
### TODO:
9+
10+
- dockerize nginx
11+
- change config to work with dockerised services

nginx/nginx.conf

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# current sorry state of my nginx.conf file
2+
worker_processes 1;
3+
4+
events {
5+
worker_connections 1024;
6+
}
7+
8+
http {
9+
include mime.types;
10+
default_type application/octet-stream;
11+
# for caching of cookie
12+
proxy_cache_path cache/ keys_zone=auth_cache:1m;
13+
14+
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
15+
# '$status $body_bytes_sent "$http_referer" '
16+
# '"$http_user_agent" "$http_x_forwarded_for"';
17+
18+
#access_log logs/access.log main;
19+
20+
sendfile on;
21+
#tcp_nopush on;
22+
23+
#keepalive_timeout 0;
24+
keepalive_timeout 65;
25+
26+
#gzip on;
27+
28+
server {
29+
listen 80;
30+
server_name localhost;
31+
32+
# frontend (i guess login page)
33+
location / {
34+
proxy_pass http://localhost:3000/; # frontend running on...similar for other services
35+
proxy_http_version 1.1;
36+
proxy_set_header Upgrade $http_upgrade;
37+
proxy_set_header Connection "Upgrade";
38+
proxy_set_header Host $host;
39+
proxy_cache_bypass $http_upgrade;
40+
}
41+
42+
# question
43+
location /api/ {
44+
proxy_pass http://localhost:9090/;
45+
}
46+
47+
# # user (pure conjecture, just referencing gaylord article)
48+
# location /users/ {
49+
# auth_request auth;
50+
# auth_request_set $userid $upstream_http_x_auth_user;
51+
52+
# # if fail go back to landing
53+
# if ($http_accept ~* "text/html" ) {
54+
# error_page 401 403 =200 /;
55+
# }
56+
# proxy_set_header X-Auth-User $userid;
57+
# proxy_set_header Host $host;
58+
# proxy_set_header X-Forwarded-For $remote_addr;
59+
# proxy_pass http://localhost:3001/;
60+
61+
# }
62+
63+
# location = auth {
64+
# internal;
65+
# # proxy_pass to authenticator service
66+
# proxy_set_header Content-Length "";
67+
# proxy_set_header X-Dbg $cookie_AUTH;
68+
69+
# proxy_cache auth_cache;
70+
# proxy_cache_valid 200 204 1m;
71+
# proxy_cache_key "$http_authorization"; # jwt?
72+
# }
73+
}
74+
}

peerprep/.env.sample

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# THIS CANNOT BE RIGHT, TEMP FIX
2+
NEXT_PUBLIC_BASE_URL=http://localhost
3+
# location of question service
4+
NEXT_PUBLIC_QUESTION_SERVICE=api
5+
NEXT_PUBLIC_USER_SERVICE=users
6+
# dev flag, originally used when services were not up
7+
DEV_ENV=not

peerprep/components/questionpage/QuestionCard.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const QuestionCard: React.FC<QuestionCardProps> = ({ question }) => {
1616
const handleDelete = async () => {
1717
if (
1818
confirm(
19-
`Are you sure you want to delete ${question.title}? (ID: ${question.id}) `,
19+
`Are you sure you want to delete ${question.title}? (ID: ${question.id}) `
2020
)
2121
) {
2222
const status = await deleteQuestion(question.id);
@@ -58,7 +58,7 @@ const QuestionCard: React.FC<QuestionCardProps> = ({ question }) => {
5858
Difficulty:{" "}
5959
<span
6060
className={`capitalize font-bold ${getDifficultyColor(
61-
question.difficulty,
61+
question.difficulty
6262
)}`}
6363
>
6464
{Difficulty[question.difficulty]}
@@ -82,7 +82,9 @@ const QuestionCard: React.FC<QuestionCardProps> = ({ question }) => {
8282
</div>
8383

8484
<div className={styles.buttonContainer}>
85-
<PeerprepButton onClick={() => router.push(`questions/${question.id}`)}>
85+
<PeerprepButton
86+
onClick={() => router.push(`/questions/${question.id}`)}
87+
>
8688
View
8789
</PeerprepButton>
8890
<PeerprepButton onClick={handleDelete}>Delete</PeerprepButton>

0 commit comments

Comments
 (0)