Ubuntu12.04+apache2.4+django Configuring the Reverse Proxy

Source: Internet
Author: User
Tags log log

Because of the project requirements, in the existing PHP project, need to run a Django+mysql project, under the same domain name, the idea is the Apache reverse proxy, the domain name of a link into the proxy.

Do a reverse proxy test on the Ubuntu machine, start a Django demo, configure a reverse proxy on Apache, and try to see if it's accessible;

Configuration

Installing the Proxy component

A2enmod proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http

Modify Configuration

sudo vim/etc/apache2/mods-enabled/proxy.conf

  

<ifmodule mod_proxy.c>        # If you want to use Apache2 as a forward proxy, uncomment the        # ' proxyrequests on ' l Ine and the <proxy *> block below.        # Warning:be careful to restrict access inside the <proxy *> block.        # Open proxy servers is dangerous both to your network and to the        # Internet at large.        #        If You are want to use apache2 as a reverse proxy/gateway        in # Front of some for Web application server, you DON ' T need        # ' proxyrequests on '.        Proxyrequests Off        <proxy *>           Require all granted        </Proxy>        # enable/disable the Handling of http/1.1 "Via:" Headers.        # ("full" adds the server version; "Block" removes all outgoing via:headers)        # Set to one Of:off | On | Full | Block        #ProxyVia off</ifmodule>

Modify Apache Virtual Host Configuration

<virtualhost *:80>        ServerName ioe1888.com        serveralias www.ioe1888.com        ServerAdmin [email Protected]        documentroot/var/www/www.ioe1888.com/        <directory/>                options-indexes +followsymlinks                  allowoverride                  All Require all granted         </Directory>        <Directory/var/www/www.ioe1888.com/>                options-indexes + FollowSymLinks                  allowoverride All                  Require all granted         </Directory>        Proxypass/demo http/ 127.0.0.1:8000/         proxypassreverse/demo http://127.0.0.1:8000/         errorlog ${apache_log_dir}/ Ioe1888-site.error.log        customlog ${apache_log_dir}/ioe1888-site.access.log combined</virtualhost>

Create a Django demo program under/var/www

$ django-admin startproject mysite$ python manage.py migrate$ python manage.py runserver

Visit the Www.ioe1888.com/demo page, error 403, check the log log, said the permissions issue

Ah01630:client denied by server configuration:proxy:http://127.0.0.1:8000/

Modify the Mysit directory to belong to the user and user group, and give 755 permissions

Chown-r www-data:www-data mysite/chmod-r 755 mysite/

Continue to access Www.ioe1888.com/demo, the Django default page appears

Django configuration MySQL database, need to install

django==1.11.5
mysqlclient==1.3.12
pytz==2017.2
requests==2.18.4
urllib3==1.22

django_settings_module= ' ieee1888.prd ' python manage.py runserver Django connected MySQL database (IEEE1888.PRD for your own)

Ubuntu12.04+apache2.4+django Configuring the Reverse Proxy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.