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
55621bc9
Commit
55621bc9
authored
Jun 21, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add redirect+
parent
7b6d37f8
Pipeline
#22333
passed with stages
in 55 minutes and 58 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
README.md
README.md
+6
-0
src/site.ts
src/site.ts
+21
-5
views/nginx.conf.mustache
views/nginx.conf.mustache
+3
-0
No files found.
README.md
View file @
55621bc9
...
...
@@ -46,6 +46,12 @@ Use `SITE_mycard.moe: php://fpm.example.com:9000/path/to/site`.
-
`EXPIRES`
Specify expires time. Default
`10m`
.
-
`PHP_EXTRA`
Extra entry in
`location`
.
#### Redirect
Use
`SITE_mycard.moe: redirect+https://example.com`
.
-
`CODE`
Specify redirect code. Default
`301`
.
### Global
-
`PURGE_ALLOWED`
IPs allowed to do PURGE request.
...
...
src/site.ts
View file @
55621bc9
...
...
@@ -42,18 +42,28 @@ interface FileRenderData extends SiteRenderData {
expires
:
string
;
}
export
interface
StaticRenderData
extends
FileRenderData
{
export
interface
StaticRenderData
extends
FileRenderData
{
static
:
true
;
browse
?:
boolean
;
}
export
interface
PhpRenderData
extends
FileRenderData
{
export
interface
PhpRenderData
extends
FileRenderData
{
php
:
true
;
upstream
:
string
;
upstream
:
string
;
phpExtra
?:
string
[];
}
export
type
SpecificRenderData
=
PhpRenderData
|
StaticRenderData
|
ProxyRenderData
;
export
interface
RedirectRenderData
extends
SiteRenderData
{
redirect
:
true
;
upstream
:
string
;
code
:
number
;
}
export
type
SpecificRenderData
=
|
PhpRenderData
|
StaticRenderData
|
ProxyRenderData
|
RedirectRenderData
;
export
interface
RenderData
{
purgeAllowed
?:
string
[];
...
...
@@ -107,7 +117,7 @@ async function getSiteData(
expires
:
parser
.
getString
(
'
EXPIRES
'
)
||
'
10m
'
,
browse
:
parser
.
getBoolean
(
'
BROWSE
'
),
}
as
StaticRenderData
;
}
else
if
(
targetUrl
.
protocol
===
'
php:
'
)
{
}
else
if
(
targetUrl
.
protocol
===
'
php:
'
)
{
specificRenderData
=
{
php
:
true
,
root
:
targetUrl
.
pathname
,
...
...
@@ -116,6 +126,12 @@ async function getSiteData(
upstream
:
targetUrl
.
host
,
phpExtra
:
parser
.
getArray
(
'
PHP_EXTRA
'
),
}
as
PhpRenderData
;
}
else
if
(
targetUrl
.
protocol
.
startsWith
(
'
redirect+
'
))
{
specificRenderData
=
{
redirect
:
true
,
upstream
:
targetUrl
.
href
.
slice
(
10
),
code
:
parser
.
getNumber
(
'
REDIRECT_CODE
'
)
||
301
,
}
as
RedirectRenderData
;
}
else
{
specificRenderData
=
{
proxy
:
true
,
...
...
views/nginx.conf.mustache
View file @
55621bc9
...
...
@@ -257,6 +257,9 @@ http {
expires
{{
expires
}}
;
try_files $uri $uri/ /
{{
index
}}
?$query_string;
{{/
php
}}
{{#
redirect
}}
return
{{
code
}}
{{
upstream
}}
;
{{/
redirect
}}
{{#
locationExtra
}}
{{
.
}}
{{/
locationExtra
}}
...
...
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