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
40fc904e
Commit
40fc904e
authored
Jul 11, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add htpasswd
parent
949133ec
Pipeline
#22640
passed with stages
in 24 minutes and 43 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
2 deletions
+36
-2
package-lock.json
package-lock.json
+12
-1
package.json
package.json
+2
-1
src/site.ts
src/site.ts
+17
-0
views/nginx.conf.mustache
views/nginx.conf.mustache
+5
-0
No files found.
package-lock.json
View file @
40fc904e
...
@@ -10,7 +10,8 @@
...
@@ -10,7 +10,8 @@
"license"
:
"MIT"
,
"license"
:
"MIT"
,
"dependencies"
:
{
"dependencies"
:
{
"lodash"
:
"^4.17.21"
,
"lodash"
:
"^4.17.21"
,
"mustache"
:
"^4.2.0"
"mustache"
:
"^4.2.0"
,
"nano-md5"
:
"^1.0.5"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"@types/jest"
:
"^28.1.6"
,
"@types/jest"
:
"^28.1.6"
,
...
@@ -3657,6 +3658,11 @@
...
@@ -3657,6 +3658,11 @@
"mustache"
:
"bin/mustache"
"mustache"
:
"bin/mustache"
}
}
},
},
"node_modules/nano-md5"
:
{
"version"
:
"1.0.5"
,
"resolved"
:
"https://registry.npmjs.org/nano-md5/-/nano-md5-1.0.5.tgz"
,
"integrity"
:
"sha512-1VAOX0EiuwAdCMGpnglxp9r6ylm+gXwQi+UPAnc/Oj1tLLJ8D1I8rLZeiO4MWsUAqH8tuBAHweT1LYSrDfJlPg=="
},
"node_modules/natural-compare"
:
{
"node_modules/natural-compare"
:
{
"version"
:
"1.4.0"
,
"version"
:
"1.4.0"
,
"resolved"
:
"https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
,
...
@@ -7537,6 +7543,11 @@
...
@@ -7537,6 +7543,11 @@
"resolved"
:
"https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz"
,
"integrity"
:
"sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ=="
"integrity"
:
"sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ=="
},
},
"nano-md5"
:
{
"version"
:
"1.0.5"
,
"resolved"
:
"https://registry.npmjs.org/nano-md5/-/nano-md5-1.0.5.tgz"
,
"integrity"
:
"sha512-1VAOX0EiuwAdCMGpnglxp9r6ylm+gXwQi+UPAnc/Oj1tLLJ8D1I8rLZeiO4MWsUAqH8tuBAHweT1LYSrDfJlPg=="
},
"natural-compare"
:
{
"natural-compare"
:
{
"version"
:
"1.4.0"
,
"version"
:
"1.4.0"
,
"resolved"
:
"https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
,
...
...
package.json
View file @
40fc904e
...
@@ -57,6 +57,7 @@
...
@@ -57,6 +57,7 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"
lodash
"
:
"
^4.17.21
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
mustache
"
:
"
^4.2.0
"
"
mustache
"
:
"
^4.2.0
"
,
"
nano-md5
"
:
"
^1.0.5
"
}
}
}
}
src/site.ts
View file @
40fc904e
import
{
pickCert
}
from
'
./check-cert
'
;
import
{
pickCert
}
from
'
./check-cert
'
;
import
{
Parser
}
from
'
./parser
'
;
import
{
Parser
}
from
'
./parser
'
;
import
{
getSiteNames
}
from
'
./utility
'
;
import
{
getSiteNames
}
from
'
./utility
'
;
import
md5
from
'
nano-md5
'
;
import
fs
from
'
fs
'
;
export
interface
SiteHttps
{
export
interface
SiteHttps
{
ports
:
number
[];
ports
:
number
[];
...
@@ -23,6 +25,7 @@ export interface SiteRenderData {
...
@@ -23,6 +25,7 @@ export interface SiteRenderData {
disableTop
?:
boolean
;
disableTop
?:
boolean
;
serverExtra
?:
string
[];
serverExtra
?:
string
[];
locationExtra
?:
string
[];
locationExtra
?:
string
[];
htpasswd
?:
string
;
}
}
export
interface
ProxyRenderData
extends
SiteRenderData
{
export
interface
ProxyRenderData
extends
SiteRenderData
{
...
@@ -145,6 +148,17 @@ async function getSiteData(
...
@@ -145,6 +148,17 @@ async function getSiteData(
}
as
ProxyRenderData
;
}
as
ProxyRenderData
;
}
}
const
basicPasswords
=
Object
.
entries
(
parser
.
getDict
(
'
HTPASSWD
'
));
if
(
basicPasswords
.
length
)
{
const
htpasswd
=
basicPasswords
.
map
(([
user
,
pass
])
=>
`
${
user
}
:
${
md5
.
crypt
(
pass
)}
`
)
.
join
(
'
\n
'
);
await
fs
.
promises
.
writeFile
(
`/etc/nginx/generated/htpasswd-
${
domain
}
`
,
htpasswd
,
);
}
return
{
return
{
domains
:
domains
,
domains
:
domains
,
ports
:
parser
.
getArrayNumber
(
'
PORT
'
)
||
[
80
],
ports
:
parser
.
getArrayNumber
(
'
PORT
'
)
||
[
80
],
...
@@ -157,6 +171,9 @@ async function getSiteData(
...
@@ -157,6 +171,9 @@ async function getSiteData(
disableTop
:
parser
.
getBoolean
(
'
DISABLE_TOP
'
),
disableTop
:
parser
.
getBoolean
(
'
DISABLE_TOP
'
),
serverExtra
:
parser
.
getArray
(
'
SERVER_EXTRA
'
),
serverExtra
:
parser
.
getArray
(
'
SERVER_EXTRA
'
),
locationExtra
:
parser
.
getArray
(
'
LOCATION_EXTRA
'
),
locationExtra
:
parser
.
getArray
(
'
LOCATION_EXTRA
'
),
htpasswd
:
basicPasswords
.
length
?
`/etc/nginx/generated/htpasswd-
${
domain
}
`
:
undefined
,
...
specificRenderData
,
...
specificRenderData
,
};
};
}
}
...
...
views/nginx.conf.mustache
View file @
40fc904e
...
@@ -195,6 +195,11 @@ http {
...
@@ -195,6 +195,11 @@ http {
}
}
{{/
disableTop
}}
{{/
disableTop
}}
{{#
htpasswd
}}
auth_basic "Please enter your username and password";
auth_basic_user_file
{{
htpasswd
}}
;
{{/
htpasswd
}}
{{#
serverExtra
}}
{{#
serverExtra
}}
{{
.
}}
{{
.
}}
{{/
serverExtra
}}
{{/
serverExtra
}}
...
...
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