Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Run the web.py app on a local port using a web server such as <a href="http://gunicorn.org/" rel="nofollow noreferrer">gunicorn</a>, then configure nginx to host static files and reverse proxy the gunicorn server. Here are some configuration snippets, assuming that:</p> <ul> <li>your project is in <code>/var/www/example-webpy</code></li> <li>your static files are in <code>example-webpy/static</code></li> <li>your nginx configuration is in <code>/etc/nginx</code>.</li> </ul> <h3>Expose the WSGI object in your application</h3> <p>It looks like web.py doesn't do this by default, so you'll want something like the following in your <code>app.py</code> (or whichever file bootstraps your app):</p> <pre><code># For serving using any wsgi server wsgi_app = web.application(urls, globals()).wsgifunc() </code></pre> <p>More information in <a href="https://stackoverflow.com/questions/13667103/web-py-and-gunicorn">this SO question</a>.</p> <h3>Run your application server</h3> <p>Install gunicorn and start your application by running something like this (where <code>example</code> is the name of your Python module):</p> <pre><code>gunicorn example:wsgi_app -b localhost:3001 </code></pre> <p>(You'll probably want to automate this using something like <a href="http://supervisord.org/" rel="nofollow noreferrer">Supervisor</a> so that the application server is restarted if your server bounces.)</p> <h3>Configure nginx</h3> <p>Put the following in <code>/etc/nginx/reverse-proxy.conf</code> (see <a href="https://stackoverflow.com/a/15547580/1402935">this SO answer</a>)</p> <pre><code># Serve / from local http server. # Just add the following to individual vhost configs: # proxy_pass http://localhost:3001/; proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_connect_timeout 10; proxy_read_timeout 10; </code></pre> <p>Then configure your domain in <code>/etc/nginx/sites-enabled/example.com.conf</code>:</p> <pre><code>server { server_name example.com location /test/ { include /etc/nginx/reverse-proxy.conf; rewrite /test/(.*) /$1 break; proxy_pass http://localhost:3001/; } location / { root /var/www/example-webpy/static/; } } </code></pre> <p>Note the rewrite, which should ensure that your web.py app never sees the /test/ URL prefix. See the nginx documentation on <a href="http://wiki.nginx.org/HttpProxyModule#proxy_pass" rel="nofollow noreferrer">proxy_pass</a> and <a href="http://wiki.nginx.org/HttpRewriteModule" rel="nofollow noreferrer">HttpRewriteModule</a>.</p> <p>This will result in requests for <code>example.com/js/main.js</code> to map to <code>example-weby/static/js/main.js</code>, so it assumes that your web.py templates didn't add a <code>/static/</code> prefix. It also results in everything in the <code>static</code> directory becoming visible to the web, so make sure that's what you intend!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload