-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathngnix.conf
44 lines (36 loc) · 1.39 KB
/
ngnix.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
server {
listen 80;
# Load environment variables from a file created on container start (it might be empty)
include "/GH_OAUTH_CLIENT.conf"; # This file may be empty or missing values
# Default to empty strings if CLIENT_ID or CLIENT_SECRET are not set
set $client_id "";
set $client_secret "";
# Check if environment variables were set, otherwise default to empty
if ($CLIENT_ID) {
set $client_id "client_id=${CLIENT_ID}";
}
if ($CLIENT_SECRET) {
set $client_secret "client_secret=${CLIENT_SECRET}";
}
# Reverse proxy to GitHub OAuth access token
location = /auth {
# Handle query arguments
set $token "";
if ($is_args) {
set $token "&";
}
# Concatenate the query arguments with client_id and client_secret, if set
set $args "${args}${token}${client_id}&${client_secret}";
# Proxy request to GitHub OAuth access token endpoint
proxy_pass https://github.com/login/oauth/access_token$is_args$args;
proxy_set_header Accept "application/json";
}
# Serve Vue.js application and handle optional URL rewrites
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
# Optional: Redirect requests that lack a trailing slash to add one
rewrite ^([^.]*[^/])$ $1/ permanent;
}
}