Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-static
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-static
Commits
3428d92b
Commit
3428d92b
authored
Mar 27, 2017
by
Terence Lee
Committed by
GitHub
Mar 27, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #65 from heroku/https_only_proxies
https_only happens over proxies
parents
0aebb10e
e31a532f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
13 deletions
+51
-13
README.md
README.md
+1
-0
nginx.conf.erb
scripts/config/templates/nginx.conf.erb
+1
-13
index.html
spec/fixtures/redirects_https_only/public_html/index.html
+1
-0
static.json
spec/fixtures/redirects_https_only/static.json
+9
-0
simple_spec.rb
spec/simple_spec.rb
+39
-0
No files found.
README.md
View file @
3428d92b
...
@@ -216,6 +216,7 @@ when accessing `/foo`, `X-Foo` will have the value `"foo"` and `X-Bar` will not
...
@@ -216,6 +216,7 @@ when accessing `/foo`, `X-Foo` will have the value `"foo"` and `X-Bar` will not
### Route Ordering
### Route Ordering
*
HTTPS redirect
*
Root Files
*
Root Files
*
Clean URLs
*
Clean URLs
*
Proxies
*
Proxies
...
...
scripts/config/templates/nginx.conf.erb
View file @
3428d92b
...
@@ -80,19 +80,6 @@ http {
...
@@ -80,19 +80,6 @@ http {
}
}
<%
end
%>
<%
end
%>
<%
proxies
.
each
do
|
location
,
hash
|
%>
set $
<%=
hash
[
'name'
]
%>
<%=
hash
[
'host'
]
%>
;
location
<%=
location
%>
{
rewrite ^
<%=
location
%>
/?(.*)
<%=
hash
[
'path'
]
%>
/$1 break;
proxy_pass $
<%=
hash
[
'name'
]
%>
;
proxy_ssl_server_name on;
# handle Location rewrites from the proxy properly
<%
%
w
(
http
https
).
each
do
|
scheme
|
%>
proxy_redirect
<%=
hash
[
"redirect_
#{
scheme
}
"
]
%>
<%=
location
%>
;
<%
end
%>
}
<%
end
%>
# need this b/c setting $fallback to =404 will try #{root}=404 instead of returning a 404
# need this b/c setting $fallback to =404 will try #{root}=404 instead of returning a 404
location @404 {
location @404 {
return 404;
return 404;
...
@@ -100,6 +87,7 @@ http {
...
@@ -100,6 +87,7 @@ http {
# fallback proxy named match
# fallback proxy named match
<%
proxies
.
each
do
|
location
,
hash
|
%>
<%
proxies
.
each
do
|
location
,
hash
|
%>
set $
<%=
hash
[
'name'
]
%>
<%=
hash
[
'host'
]
%>
;
location @
<%=
location
%>
{
location @
<%=
location
%>
{
rewrite ^
<%=
location
%>
/?(.*)$
<%=
hash
[
'path'
]
%>
/$1 break;
rewrite ^
<%=
location
%>
/?(.*)$
<%=
hash
[
'path'
]
%>
/$1 break;
# can reuse variable set above
# can reuse variable set above
...
...
spec/fixtures/redirects_https_only/public_html/index.html
0 → 100644
View file @
3428d92b
hello world
spec/fixtures/redirects_https_only/static.json
0 → 100644
View file @
3428d92b
{
"redirects"
:
{
"/old/gone"
:
{
"url"
:
"/"
,
"status"
:
302
}
},
"https_only"
:
true
}
spec/simple_spec.rb
View file @
3428d92b
...
@@ -129,6 +129,16 @@ RSpec.describe "Simple" do
...
@@ -129,6 +129,16 @@ RSpec.describe "Simple" do
expect
(
response
[
"location"
]).
to
eq
(
"http://
#{
RouterRunner
::
HOST_IP
}
/interpolation.html"
)
expect
(
response
[
"location"
]).
to
eq
(
"http://
#{
RouterRunner
::
HOST_IP
}
/interpolation.html"
)
end
end
end
end
context
"https_only"
do
let
(
:name
)
{
"redirects_https_only"
}
it
"should redirect to https first"
do
response
=
app
.
get
(
"/old/gone"
)
expect
(
response
.
code
).
to
eq
(
"301"
)
expect
(
response
[
"location"
]).
to
eq
(
"https://
#{
RouterRunner
::
HOST_IP
}
/old/gone"
)
end
end
end
end
describe
"https only"
do
describe
"https only"
do
...
@@ -259,6 +269,35 @@ STATIC_JSON
...
@@ -259,6 +269,35 @@ STATIC_JSON
end
end
end
end
context
"https_only"
do
let
(
:setup_static_json
)
do
Proc
.
new
do
|
path
|
File
.
open
(
static_json_path
,
"w"
)
do
|
file
|
file
.
puts
<<
STATIC_JSON
{
"proxies": {
"/api/": {
"origin": "http://
#{
@proxy_ip_address
}#{
path
}
"
}
},
"https_only": true
}
STATIC_JSON
end
end
end
before
do
setup_static_json
.
call
(
"/"
)
end
it
"should not redirect direct to the proxy"
do
response
=
app
.
get
(
"/api/bar"
)
expect
(
response
.
code
).
to
eq
(
"301"
)
expect
(
response
[
"Location"
]).
to
eq
(
"https://
#{
RouterRunner
::
HOST_IP
}
/api/bar"
)
end
end
context
"env var substitution"
do
context
"env var substitution"
do
let
(
:proxy
)
do
let
(
:proxy
)
do
<<
CONFIG_RU
<<
CONFIG_RU
...
...
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