Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito
Commits
d580e08f
Commit
d580e08f
authored
9 years ago
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hopefully fix wrong urls with managetests
parent
1e6cc20c
develop
dev-shadmod-auto-download-toml
dev-shadmod-news
docs
shadmod-log-config
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
uitwww/__main__.py
uitwww/__main__.py
+1
-1
uitwww/utils.py
uitwww/utils.py
+36
-0
No files found.
uitwww/__main__.py
View file @
d580e08f
...
...
@@ -38,7 +38,7 @@ def cli():
@
click
.
option
(
"-d"
,
"--debug"
,
help
=
"Enable debug mode"
,
is_flag
=
True
)
def
run
(
cache
,
gunicorn_config
,
port
,
public
,
workers
,
debug
):
# Create the application instance
app
=
u
itwww
.
create_app
(
cache
)
app
=
u
tils
.
ReverseProxied
(
uitwww
.
create_app
(
cache
)
)
host
=
"127.0.0.1"
if
public
:
...
...
This diff is collapsed.
Click to expand it.
uitwww/utils.py
View file @
d580e08f
...
...
@@ -49,3 +49,39 @@ class GunicornInstance(baseapp.BaseApplication):
if
self
.
app
is
None
:
raise
RuntimeError
(
"Application object not set"
)
return
self
.
app
class
ReverseProxied
:
'''Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
different than what is used locally.
Created by Peter Hansen and released in the public domain.
In nginx:
location /myprefix {
proxy_pass http://192.168.0.1:5001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /myprefix;
}
:param app: the WSGI application
'''
def
__init__
(
self
,
app
):
self
.
app
=
app
def
__call__
(
self
,
environ
,
start_response
):
script_name
=
environ
.
get
(
'HTTP_X_SCRIPT_NAME'
,
''
)
if
script_name
:
environ
[
'SCRIPT_NAME'
]
=
script_name
path_info
=
environ
[
'PATH_INFO'
]
if
path_info
.
startswith
(
script_name
):
environ
[
'PATH_INFO'
]
=
path_info
[
len
(
script_name
):]
scheme
=
environ
.
get
(
'HTTP_X_SCHEME'
,
''
)
if
scheme
:
environ
[
'wsgi.url_scheme'
]
=
scheme
return
self
.
app
(
environ
,
start_response
)
This diff is collapsed.
Click to expand it.
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