mirror of
https://github.com/balkian/balkian.github.com.git
synced 2024-12-25 17:58:12 +00:00
231 lines
12 KiB
HTML
231 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
<title></title>
|
|
<meta name="viewport" content="width=device-width">
|
|
|
|
<!-- syntax highlighting CSS -->
|
|
<link rel="stylesheet" href="/theme/css/solarized.css">
|
|
<!--<link href="/css/bootstrap.css" rel="stylesheet">-->
|
|
<link rel="stylesheet" href="/theme/font-awesome/css/font-awesome.min.css">
|
|
|
|
<!--<link rel="stylesheet" href="/css/bootstrap-responsive.min.css">-->
|
|
|
|
<!-- Custom CSS -->
|
|
<link rel="stylesheet" media="only screen" href="/theme/css/main.css">
|
|
<link rel="stylesheet" media="only screen and (min-width: 0px) and (max-width: 599px)" href="/theme/css/main-xs.css">
|
|
<link rel="stylesheet" media="only screen and (min-width: 600px) and (max-width: 1199px)" href="/theme/css/main-medium.css">
|
|
<link rel="stylesheet" media="only screen and (min-width: 1200px)" href="/theme/css/main-desktop.css">
|
|
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300|Comfortaa' rel='stylesheet' type='text/css'>
|
|
</head>
|
|
<body>
|
|
<div id="container" class="container">
|
|
<header id="header">
|
|
<div id="navbar" class="navbar navbar-inverse navbar-static-bottom">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<ul class="nav navbar-nav">
|
|
<li class="active" >
|
|
<a href="/"><i class="icon-home icon-large"></i></a>
|
|
</li>
|
|
<li >
|
|
<a href="/pages/about.html">About</a>
|
|
</li>
|
|
<li >
|
|
<a href="/pages/projects.html">Projects</a>
|
|
</li>
|
|
<li >
|
|
<a href="/pages/to-do.html">To-Do</a>
|
|
</li>
|
|
<li>
|
|
<a href="//jfernando.es" target="_blank">CV</a>
|
|
</li>
|
|
<!--<li class="dropdown">-->
|
|
<!--<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>-->
|
|
<!--<ul class="dropdown-menu">-->
|
|
<!--<li><a href="#">Action</a></li>-->
|
|
<!--<li><a href="#">Another action</a></li>-->
|
|
<!--<li><a href="#">Something else here</a></li>-->
|
|
<!--<li class="divider"></li>-->
|
|
<!--<li class="dropdown-header">Nav header</li>-->
|
|
<!--<li><a href="#">Separated link</a></li>-->
|
|
<!--<li><a href="#">One more separated link</a></li>-->
|
|
<!--</ul>-->
|
|
<!--</li>-->
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<div id="contentwrapper">
|
|
<div id="sidebar" >
|
|
<div id="badge" class="flip-container" ontouchstart="this.classList.toggle('hover');">
|
|
<div class="flipper sticky">
|
|
<div class="front">
|
|
<!-- front content -->
|
|
<img id="avatar" width=100% src="/theme/img/me.png">
|
|
</div>
|
|
<div class="back">
|
|
<!-- back content -->
|
|
<img id="picture" width=100% src="/theme/img/me-bat.png">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="entries">
|
|
<h1 class="title">Latest entries</h1>
|
|
<dl>
|
|
<dt><a href="/sharing-dotfiles.html">Sharing dotfiles</a></dt>
|
|
<a class="tag" href="/tag/github.html"><dd class="label label-default">github</dd></a>
|
|
<a class="tag" href="/tag/git.html"><dd class="label label-default">git</dd></a>
|
|
<a class="tag" href="/tag/dotfiles.html"><dd class="label label-default">dotfiles</dd></a>
|
|
<dt><a href="/zotero.html">Zotero</a></dt>
|
|
<a class="tag" href="/tag/zotero.html"><dd class="label label-default">zotero</dd></a>
|
|
<a class="tag" href="/tag/webdav.html"><dd class="label label-default">webdav</dd></a>
|
|
<a class="tag" href="/tag/nginx.html"><dd class="label label-default">nginx</dd></a>
|
|
<a class="tag" href="/tag/apache.html"><dd class="label label-default">apache</dd></a>
|
|
<dt><a href="/proxies-with-apache-and-python.html">Proxies with Apache and python</a></dt>
|
|
<a class="tag" href="/tag/python.html"><dd class="label label-default">python</dd></a>
|
|
<a class="tag" href="/tag/apache.html"><dd class="label label-default">apache</dd></a>
|
|
<a class="tag" href="/tag/proxy.html"><dd class="label label-default">proxy</dd></a>
|
|
<a class="tag" href="/tag/gunicorn.html"><dd class="label label-default">gunicorn</dd></a>
|
|
<a class="tag" href="/tag/uwsgi.html"><dd class="label label-default">uwsgi</dd></a>
|
|
<dt><a href="/publishing-in-pypi.html">Publishing in PyPi</a></dt>
|
|
<a class="tag" href="/tag/github.html"><dd class="label label-default">github</dd></a>
|
|
<a class="tag" href="/tag/python.html"><dd class="label label-default">python</dd></a>
|
|
<a class="tag" href="/tag/pypi.html"><dd class="label label-default">pypi</dd></a>
|
|
<dt><a href="/updating-eurolovemap.html">Updating EuroLoveMap</a></dt>
|
|
<a class="tag" href="/tag/javascript.html"><dd class="label label-default">javascript</dd></a>
|
|
<a class="tag" href="/tag/python.html"><dd class="label label-default">python</dd></a>
|
|
<a class="tag" href="/tag/heroku.html"><dd class="label label-default">heroku</dd></a>
|
|
</dl>
|
|
</div>
|
|
<!--Sidebar content-->
|
|
</div>
|
|
<div id="content">
|
|
<!--Body content-->
|
|
<div class="postnav">
|
|
<a href="publishing-in-pypi.html"><span class="previouspost"><i class="icon-chevron-sign-left"></i> Publishing in PyPi</a></span>
|
|
<span class='nextpost'><a href="/zotero.html">Zotero <i class="icon-chevron-sign-right"></i></span></a>
|
|
</div>
|
|
<div class="posthead">
|
|
<h2 class="title">Proxies with Apache and python</h2>
|
|
<span class="meta date">2014-10-09</span>
|
|
<a class="tag" href="/tag/python.html"><span class="label label-default">python</span></a>
|
|
<a class="tag" href="/tag/apache.html"><span class="label label-default">apache</span></a>
|
|
<a class="tag" href="/tag/proxy.html"><span class="label label-default">proxy</span></a>
|
|
<a class="tag" href="/tag/gunicorn.html"><span class="label label-default">gunicorn</span></a>
|
|
<a class="tag" href="/tag/uwsgi.html"><span class="label label-default">uwsgi</span></a>
|
|
</div>
|
|
|
|
<div class="post">
|
|
<p>This is a quick note on proxying a local python application (e.g. flask)
|
|
to a subdirectory in Apache. This assumes that the file wsgi.py contains
|
|
a WSGI application with the name <em>application</em>. Hence, wsgi:application.</p>
|
|
<div class="section" id="gunicorn">
|
|
<h2>Gunicorn</h2>
|
|
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
|
|
2
|
|
3
|
|
4
|
|
5</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt"><Location</span> <span class="s">/myapp/</span><span class="nt">></span>
|
|
<span class="nb">ProxyPass</span> http://127.0.0.1:8888/myapp/
|
|
<span class="nb">ProxyPassReverse</span> http://127.0.0.1:8888/myapp/
|
|
<span class="nb">RequestHeader</span> set SCRIPT_NAME <span class="s2">"/myapp/"</span>
|
|
<span class="nt"></Location></span>
|
|
</pre></div>
|
|
</td></tr></table><p><strong>Important</strong>: <em>SCRIPT_NAME</em> and the end of <em>ProxyPass</em> URL <strong>MUST BE
|
|
THE SAME</strong>. Otherwise, Gunicorn will fail miserably.</p>
|
|
<p>Try it with:</p>
|
|
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>venv/bin/gunicorn -w <span class="m">4</span> -b 127.0.0.1:8888 --log-file - --access-logfile - wsgi:application
|
|
</pre></div>
|
|
</td></tr></table></div>
|
|
<div class="section" id="uwsgi">
|
|
<h2>UWSGI</h2>
|
|
<p>This is a very simple configuration. I will try to upload one with more
|
|
options for uwsgi (in a .ini file).</p>
|
|
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
|
|
2
|
|
3
|
|
4</pre></div></td><td class="code"><div class="highlight"><pre><span class="nt"><Location</span> <span class="s">/myapp/</span><span class="nt">></span>
|
|
<span class="nb">SetHandler</span> uwsgi_handler
|
|
<span class="nb">uWSGISocker</span> <span class="m">127.0.0.1</span>:8888
|
|
<span class="nt"></Location></span>
|
|
</pre></div>
|
|
</td></tr></table><p>Try it with:</p>
|
|
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre>uwsgi --socket 127.0.0.1:8888 -w wsgi:application
|
|
</pre></div>
|
|
</td></tr></table><div class="section" id="extra-supervisor">
|
|
<h3>Extra: Supervisor</h3>
|
|
<p>If everything went as expected, you can wrap your command in a
|
|
supervisor config file and let it handle the server for you.</p>
|
|
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19</pre></div></td><td class="code"><div class="highlight"><pre><span class="k">[unix_http_server]</span>
|
|
<span class="na">file</span><span class="o">=</span><span class="s">/tmp/myapp.sock ; path to your socket file</span>
|
|
|
|
<span class="k">[supervisord]</span>
|
|
<span class="na">logfile</span> <span class="o">=</span> <span class="s">%(here)s/logs/supervisor.log</span>
|
|
<span class="na">childlogdir</span> <span class="o">=</span> <span class="s">%(here)s/logs/</span>
|
|
|
|
<span class="k">[rpcinterface:supervisor]</span>
|
|
<span class="na">supervisor.rpcinterface_factory</span> <span class="o">=</span> <span class="s">supervisor.rpcinterface:make_main_rpcinterface</span>
|
|
|
|
<span class="k">[supervisorctl]</span>
|
|
<span class="na">logfile</span> <span class="o">=</span> <span class="s">%(here)s/logs/supervisorctl.log</span>
|
|
<span class="na">serverurl</span><span class="o">=</span><span class="s">unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket</span>
|
|
|
|
<span class="k">[program:myapp]</span>
|
|
<span class="na">command</span> <span class="o">=</span> <span class="s">venv/bin/gunicorn -w 4 -b 0.0.0.0:5000 --log-file %(here)s/logs/gunicorn.log --access-logfile - wsgi:application</span>
|
|
<span class="na">directory</span> <span class="o">=</span> <span class="s">%(here)s</span>
|
|
<span class="na">environment</span> <span class="o">=</span> <span class="s">PATH=%(here)s/venv/bin/</span>
|
|
<span class="na">logfile</span> <span class="o">=</span> <span class="s">%(here)s/logs/myapp.log</span>
|
|
</pre></div>
|
|
</td></tr></table></div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
<footer role="contentinfo">
|
|
<div class="contact">
|
|
<p>
|
|
J. Fernando Sánchez Rada | balkian
|
|
</p>
|
|
</div>
|
|
<ul id="social">
|
|
<li><a href="http://github.com/balkian"><i class="icon-github"></i></a></li>
|
|
<li><a href="http://bitbucket.com/balkian"><i class="icon-bitbucket"></i></a></li>
|
|
<li><a href="http://twitter.com/balkian"><i class="icon-twitter"></i></a></li>
|
|
<li><a href="https://plus.google.com/u/0/111897020957944410316"><i class="icon-google-plus"></i></a></li>
|
|
<li><a href="http://linkedin.com/in/jfsanchezrada"><i class="icon-linkedin"></i></a></li>
|
|
<li><a href="http://facebook.com/balkian"><i class="icon-facebook-sign"></i></a></li>
|
|
</ul>
|
|
<p>
|
|
Creative Commons A-SA-NC
|
|
</p>
|
|
</footer>
|
|
</div>
|
|
|
|
<script src="/theme/js/jquery-2.0.2.min.js"></script>
|
|
<!--<script src="/js/bootstrap.min.js"></script>-->
|
|
</body>
|
|
</html> |