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
80984b5e
Commit
80984b5e
authored
Apr 13, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for static and php
parent
216d91a7
Pipeline
#21205
canceled with stages
in 6 minutes and 34 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
49 deletions
+138
-49
src/site.ts
src/site.ts
+63
-13
views/nginx.conf.mustache
views/nginx.conf.mustache
+75
-36
No files found.
src/site.ts
View file @
80984b5e
...
@@ -20,18 +20,40 @@ export interface SiteRenderData {
...
@@ -20,18 +20,40 @@ export interface SiteRenderData {
https
?:
SiteHttps
;
https
?:
SiteHttps
;
headers
?:
Header
[];
headers
?:
Header
[];
normalizeDomain
?:
string
;
normalizeDomain
?:
string
;
minio
?:
boolean
;
disableTop
?:
boolean
;
disableTop
?:
boolean
;
serverExtra
?:
string
[];
locationExtra
?:
string
[];
}
export
interface
ProxyRenderData
extends
SiteRenderData
{
proxy
:
true
;
minio
?:
boolean
;
timeout
?:
number
;
upstream
:
string
;
noVerifyCerts
?:
boolean
;
noVerifyCerts
?:
boolean
;
noBuffer
?:
boolean
;
noBuffer
?:
boolean
;
sni
?:
boolean
;
sni
?:
boolean
;
noCache
?:
boolean
;
noCache
?:
boolean
;
upstream
:
string
;
timeout
?:
number
;
serverExtra
?:
string
[];
locationExtra
?:
string
[];
}
}
interface
FileRenderData
extends
SiteRenderData
{
root
:
string
;
index
:
string
;
expires
:
string
;
}
export
interface
StaticRenderData
extends
FileRenderData
{
static
:
true
;
browse
?:
boolean
;
}
export
interface
PhpRenderData
extends
FileRenderData
{
php
:
true
;
upstream
:
string
;
}
export
type
SpecificRenderData
=
PhpRenderData
|
StaticRenderData
|
ProxyRenderData
;
export
interface
RenderData
{
export
interface
RenderData
{
purgeAllowed
?:
string
[];
purgeAllowed
?:
string
[];
externalRealIp
?:
boolean
;
externalRealIp
?:
boolean
;
...
@@ -44,12 +66,13 @@ export interface RenderData {
...
@@ -44,12 +66,13 @@ export interface RenderData {
certsPath
:
string
;
certsPath
:
string
;
sites
:
SiteRenderData
[];
sites
:
SiteRenderData
[];
httpExtra
?:
string
[];
httpExtra
?:
string
[];
nginxExtra
?:
string
[];
}
}
async
function
getSiteData
(
async
function
getSiteData
(
domain
:
string
,
domain
:
string
,
input
:
Record
<
string
,
string
>
=
process
.
env
,
input
:
Record
<
string
,
string
>
=
process
.
env
,
):
Promise
<
S
ite
RenderData
>
{
):
Promise
<
S
pecific
RenderData
>
{
const
parser
=
new
Parser
(
`SITE_
${
domain
}
_`
,
input
);
const
parser
=
new
Parser
(
`SITE_
${
domain
}
_`
,
input
);
let
https
:
SiteHttps
;
let
https
:
SiteHttps
;
const
httpsCert
=
parser
.
getString
(
'
HTTPS
'
);
const
httpsCert
=
parser
.
getString
(
'
HTTPS
'
);
...
@@ -71,6 +94,38 @@ async function getSiteData(
...
@@ -71,6 +94,38 @@ async function getSiteData(
};
};
}
}
}
}
const
targetUrl
=
new
URL
(
input
[
`SITE_
${
domain
}
`
]);
let
specificRenderData
:
SpecificRenderData
;
if
(
targetUrl
.
protocol
===
'
static:
'
)
{
specificRenderData
=
{
static
:
true
,
root
:
targetUrl
.
pathname
,
index
:
parser
.
getString
(
'
INDEX
'
)
||
'
index.html
'
,
expires
:
parser
.
getString
(
'
EXPIRES
'
)
||
'
10m
'
,
browse
:
parser
.
getBoolean
(
'
BROWSE
'
),
}
as
StaticRenderData
;
}
else
if
(
targetUrl
.
protocol
===
'
php:
'
)
{
specificRenderData
=
{
php
:
true
,
root
:
targetUrl
.
pathname
,
index
:
parser
.
getString
(
'
INDEX
'
)
||
'
index.php
'
,
expires
:
parser
.
getString
(
'
EXPIRES
'
)
||
'
10m
'
,
upstream
:
targetUrl
.
host
,
}
as
PhpRenderData
;
}
else
{
specificRenderData
=
{
proxy
:
true
,
upstream
:
input
[
`SITE_
${
domain
}
`
],
noVerifyCerts
:
parser
.
getBoolean
(
'
NO_VERIFY_CERTS
'
),
noBuffer
:
parser
.
getBoolean
(
'
NO_BUFFER
'
),
sni
:
parser
.
getBoolean
(
'
SNI
'
),
noCache
:
parser
.
getBoolean
(
'
NO_CACHE
'
),
minio
:
parser
.
getBoolean
(
'
MINIO
'
),
timeout
:
parser
.
getNumber
(
'
TIMEOUT
'
),
}
as
ProxyRenderData
;
}
return
{
return
{
domains
:
domains
,
domains
:
domains
,
ports
:
parser
.
getArrayNumber
(
'
PORT
'
)
||
[
80
],
ports
:
parser
.
getArrayNumber
(
'
PORT
'
)
||
[
80
],
...
@@ -80,16 +135,10 @@ async function getSiteData(
...
@@ -80,16 +135,10 @@ async function getSiteData(
value
,
value
,
})),
})),
normalizeDomain
:
parser
.
getString
(
'
NORMALIZE_DOMAIN
'
),
normalizeDomain
:
parser
.
getString
(
'
NORMALIZE_DOMAIN
'
),
minio
:
parser
.
getBoolean
(
'
MINIO
'
),
disableTop
:
parser
.
getBoolean
(
'
DISABLE_TOP
'
),
disableTop
:
parser
.
getBoolean
(
'
DISABLE_TOP
'
),
noVerifyCerts
:
parser
.
getBoolean
(
'
NO_VERIFY_CERTS
'
),
noBuffer
:
parser
.
getBoolean
(
'
NO_BUFFER
'
),
sni
:
parser
.
getBoolean
(
'
SNI
'
),
noCache
:
parser
.
getBoolean
(
'
NO_CACHE
'
),
upstream
:
input
[
`SITE_
${
domain
}
`
],
timeout
:
parser
.
getNumber
(
'
TIMEOUT
'
),
serverExtra
:
parser
.
getArray
(
'
SERVER_EXTRA
'
),
serverExtra
:
parser
.
getArray
(
'
SERVER_EXTRA
'
),
locationExtra
:
parser
.
getArray
(
'
LOCATION_EXTRA
'
),
locationExtra
:
parser
.
getArray
(
'
LOCATION_EXTRA
'
),
...
specificRenderData
,
};
};
}
}
...
@@ -113,5 +162,6 @@ export async function getData(
...
@@ -113,5 +162,6 @@ export async function getData(
getSiteNames
().
map
((
domain
)
=>
getSiteData
(
domain
,
input
)),
getSiteNames
().
map
((
domain
)
=>
getSiteData
(
domain
,
input
)),
),
),
httpExtra
:
parser
.
getArray
(
'
HTTP_EXTRA
'
),
httpExtra
:
parser
.
getArray
(
'
HTTP_EXTRA
'
),
nginxExtra
:
parser
.
getArray
(
'
NGINX_EXTRA
'
),
};
};
}
}
views/nginx.conf.mustache
View file @
80984b5e
...
@@ -191,46 +191,81 @@ http {
...
@@ -191,46 +191,81 @@ http {
{{/
serverExtra
}}
{{/
serverExtra
}}
location / {
location / {
proxy_set_header X-Real-IP $remote_addr;
{{#
proxy
}}
proxy_set_header Forwarded "for=$remote_addr;by=$hostname";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Forwarded "for=$remote_addr;by=$hostname";
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
{{#
timeout
}}
proxy_set_header X-Forwarded-Host $http_host;
proxy_read_timeout
{{
.
}}
s;
{{#
timeout
}}
send_timeout
{{
.
}}
s;
proxy_read_timeout
{{
.
}}
s;
proxy_send_timeout
{{
.
}}
s;
send_timeout
{{
.
}}
s;
{{/
timeout
}}
proxy_send_timeout
{{
.
}}
s;
{{^
minio
}}
{{/
timeout
}}
proxy_set_header X-Forwarded-Proto $scheme;
{{^
minio
}}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
{{/
minio
}}
proxy_set_header Connection $connection_upgrade;
{{#
minio
}}
{{/
minio
}}
proxy_set_header Host $http_host;
{{#
minio
}}
proxy_connect_timeout 300;
proxy_set_header Host $http_host;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_connect_timeout 300;
proxy_http_version 1.1;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_set_header Connection "";
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_set_header Connection "";
{{/
minio
}}
chunked_transfer_encoding off;
{{#
noVerifyCerts
}}
{{/
minio
}}
proxy_ssl_verify off;
{{#
noVerifyCerts
}}
{{/
noVerifyCerts
}}
proxy_ssl_verify off;
{{#
noBuffer
}}
{{/
noVerifyCerts
}}
proxy_buffering off;
{{#
noBuffer
}}
{{/
noBuffer
}}
proxy_buffering off;
{{#
sni
}}
{{/
noBuffer
}}
proxy_ssl_server_name on;
{{#
sni
}}
{{/
sni
}}
proxy_ssl_server_name on;
{{#
noCache
}}
{{/
sni
}}
proxy_cache off;
{{#
noCache
}}
{{/
noCache
}}
proxy_cache off;
proxy_pass
{{
upstream
}}
;
{{/
noCache
}}
proxy_pass
{{
upstream
}}
;
{{/
proxy
}}
{{#
static
}}
root
{{
root
}}
;
expires
{{
expires
}}
;
{{#
browse
}}
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
{{/
browse
}}
{{^
browse
}}
index
{{
index
}}
;
try_files $uri $uri/ /
{{
index
}}
;
{{/
browse
}}
{{/
static
}}
{{#
php
}}
root
{{
root
}}
;
index
{{
index
}}
;
expires
{{
expires
}}
;
try_files $uri $uri/ /
{{
index
}}
?$query_string;
{{/
php
}}
{{#
locationExtra
}}
{{#
locationExtra
}}
{{
.
}}
{{
.
}}
{{/
locationExtra
}}
{{/
locationExtra
}}
}
}
{{#
php
}}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass
{{
upstream
}}
;
fastcgi_index
{{
index
}}
;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
{{#
https
}}
fastcgi_param HTTPS on;
{{/
https
}}
}
{{/
php
}}
}
}
{{/
sites
}}
{{/
sites
}}
...
@@ -244,3 +279,7 @@ http {
...
@@ -244,3 +279,7 @@ http {
stream {
stream {
include /etc/nginx/stream/*.conf;
include /etc/nginx/stream/*.conf;
}
}
{{#
nginxExtra
}}
{{
.
}}
{{/
nginxExtra
}}
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