Running a tornado app and hosting on a different port

I have a Tornado web chat that must absolutely run on port 80 by default for various reasons like authentication, etc. However, the Tornado webserver runs on port 8800 for obvious reasons (if it is possible to host Tornado on the same port as my site, I would like to try), so I am trying to start the Tornado webserver through the console, hosting the Tornado web chat on my web -site by default.

I have translated the index.html web chat to my website default folders, so it looks like www.example.com/webchat.html and not www.example.com:8800/webchat . Then I start the tornado with the command

python webchat.py 

      

But when I visit webchat.html the chat doesn't work as if it was on port 8800 because the page does not pass python.

Webchat HTML

<div class="container" style="width: auto; height: 100%;">

         <span>{% raw content %}</span> <!-- The span is not rendered on page -->



</div><!-- /.container -->

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>

{% if 'chat' in globals() and chat %}
    <!-- Application script -->
    <script src="{{ static_url('stuff.js') }}" type="text/javascript"></script>
        {% end %}

      

+3


source to share


1 answer


I can offer two options:

  • If your site is static, you can shut down the Apache server, move your site to a tornado, and get a tornado to serve your site along the way /

    . Then launch a tornado on port 80. This is probably the easiest. Add the following as the last tornado handler:

    (r'/(.*)', tornado.web.StaticFileHandler, {'path': static_path}),

    static_path

    there should be a path to your web site root directory supported by apache.

  • If you need apache server, you can configure apache as a reverse proxy for your tornado server. From Need help setting up: Apache Reverse Proxy , it looks like you need to add this to your apache.conf

    :

    ProxyPass /webchat http://localhost:8800/webchat ProxyPassReverse /webchat http://localhost:8800/webchat

    You will also need to load the specified Apache modules.



You can also try using Tornado's WSGI features and then configure Apache with mod_wsgi

.

+1


source







All Articles