Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
nginx-proxy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
nginx-proxy
Commits
477b9a6e
Commit
477b9a6e
authored
Mar 27, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support non-standard port
parent
a58072a1
Pipeline
#26094
failed with stages
in 60 minutes and 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
README.md
README.md
+2
-2
src/site.ts
src/site.ts
+13
-6
No files found.
README.md
View file @
477b9a6e
...
...
@@ -9,13 +9,13 @@ Nginx with only env var conf.
Site variables should be followed after
`SITE_<domain>_`
.
-
`SITE_mycard.moe`
Site and origin. eg.
`SITE_mycard.moe=http://localhost:3000`
-
`PORT`
-
`HTTPS`
Enable HTTPS and specify cert.
-
`HTTPS_PORT`
-
`HTTPS_NOREDIR`
Disable redirect to HTTPS.
-
`HSTS`
Enable HSTS.
-
`HEADER`
Extra header. eg.
`SITE_mycard.moe_HEADER_FOO=bar`
-
`DISABLE_TOP`
Disable / access.
-
`HTPASSWD_username`
Enable basic auth, and specify username and password.
-
`CORS`
Enable CORS.
-
`SERVER_EXTRA`
Extra entry in
`server`
.
-
`LOCATION_EXTRA`
Extra entry in
`location`
.
...
...
src/site.ts
View file @
477b9a6e
...
...
@@ -91,9 +91,11 @@ async function getSiteData(
input
:
Record
<
string
,
string
>
=
process
.
env
,
):
Promise
<
SpecificRenderData
>
{
const
parser
=
new
Parser
(
`SITE_
${
domain
}
_`
,
input
);
const
[
hostname
,
port
]
=
domain
.
split
(
'
:
'
);
const
ports
=
[
port
||
'
80
'
];
let
https
:
SiteHttps
;
const
httpsCert
=
parser
.
getString
(
'
HTTPS
'
);
const
domains
=
domain
.
split
(
'
+
'
);
const
domains
=
hostname
.
split
(
'
+
'
);
if
(
httpsCert
!==
'
0
'
&&
httpsCert
!==
'
false
'
)
{
const
cert
=
!
httpsCert
||
...
...
@@ -103,16 +105,21 @@ async function getSiteData(
?
pickCert
(
domains
)
:
httpsCert
;
if
(
cert
)
{
if
(
port
)
{
ports
.
pop
();
}
https
=
{
cert
,
ports
:
parser
.
getArray
(
'
HTTPS_PORT
'
)
||
[
'
443
'
],
redirect
:
!
parser
.
getBoolean
(
'
HTTPS_NOREDIR
'
),
ports
:
[
port
||
'
443
'
],
redirect
:
!
parser
.
getBoolean
(
'
HTTPS_NOREDIR
'
)
&&
!
port
,
hsts
:
parser
.
getBoolean
(
'
HSTS
'
),
};
}
}
const
targetUrl
=
new
URL
(
input
[
`SITE_
${
domain
}
`
]);
const
targetUrlInput
=
input
[
`SITE_
${
domain
}
`
];
const
targetUrlInputs
=
targetUrlInput
.
split
(
'
,
'
);
// TODO: support multiple targets as upstream
const
targetUrl
=
new
URL
(
targetUrlInputs
[
0
]);
let
specificRenderData
:
SpecificRenderData
;
if
(
targetUrl
.
protocol
===
'
static:
'
)
{
specificRenderData
=
{
...
...
@@ -141,7 +148,7 @@ async function getSiteData(
const
sni
=
parser
.
getString
(
'
SNI
'
);
specificRenderData
=
{
proxy
:
true
,
upstream
:
input
[
`SITE_
${
domain
}
`
]
,
upstream
:
targetUrlInput
,
noVerifyCerts
:
parser
.
getBoolean
(
'
NO_VERIFY_CERTS
'
),
noBuffer
:
parser
.
getBoolean
(
'
NO_BUFFER
'
),
sni
:
sni
===
'
1
'
,
...
...
@@ -166,7 +173,7 @@ async function getSiteData(
return
{
domains
:
domains
,
ports
:
parser
.
getArray
(
'
PORT
'
)
||
[
'
80
'
]
,
ports
,
https
,
headers
:
Object
.
entries
(
parser
.
getDict
(
'
HEADER
'
)).
map
(([
name
,
value
])
=>
({
name
:
name
.
replace
(
/_/g
,
'
-
'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment