Como definir um servidor que envie a solicitação para minha API?

0

Eu estou trabalhando com Linux, Ubuntu e uma API feita no Django.

Minhas perguntas são:

  1. Como configuro um servidor (preferencialmente no apache) para enviar solicitações http para minha API?

  2. Como faço para 'capturar' os dados na minha API?

Desculpe se minhas dúvidas estão confusas ou incertas, sou relativamente novo neste domínio.

    
por Hellas 14.07.2016 / 16:29

3 respostas

0

Corrigido!

Longa história curta Eu criei outra API simples em execução em uma porta diferente.

Eu usei:

  1. método POST na API # 1 com um simples botão de envio (json) e configuração para enviá-lo para o IP / PORT da API # 2
  2. GET método na API # 2 (o resultado só pode ser visto no terminal, mas isso é tudo que eu precisava)
por Hellas 20.07.2016 / 10:55
0

Não tenho certeza, mas eu acho que você está procurando por um "proxy reverso" - dê uma olhada no proxy mod do apache2:

ProxyPass "/foo" "http://foo.example.com/bar"
ProxyPassReverse "/foo" "http://foo.example.com/bar"

( link )

    
por Phillip -Zyan K Lee- Stockmann 14.07.2016 / 20:54
0

Apache:

    Option 1:

            -- sudo apt-get install apache2 apache2-doc apache2-utils

    Option 2: latest one from the source code

            Steps:

                 Apache Tar file :

                    -- wget http://www.apache.org/dist/httpd/httpd-2.4.20.tar.gz

                 Dependancy tar files:

                    -- wget http://www.apache.org/dist/apr/apr-1.5.2.tar.gz
                    -- wget http://www.apache.org/dist/apr/apr-util-1.5.4.tar.gz
                    -- wget http://www.apache.org/dist/apr/apr-iconv-1.2.1.tar.gz

                 Before apache installation:

                    -- sudo apt-get install libtool autoconf gcc g++ libpcre3 libpcre3-dev

                 Unzip the apache tar files:
                         -- tar -xvf httpd-2.4.20.tar.gz
                         -- cd httpd-2.4.20/
                         -- Untar the "apr"(apr-1.5.2.tar.gz, apr-util-1.5.4.tar.gz and apr-iconv-1.2.1.tar.gz) files
                         -- put it on httpd-2.4.20/srclib/ without version info

                 installing apache2 on /usr/local/apache2:

                 -- ./configure --prefix=/usr/local/apache2
                 --  make
                 -- make install
                 -- Add "ServerName localhost" at conf/http.conf file
                 -- Change the listen port as whatever you want

mod_wsgi:

    -- Apache Requirements
            --Apache 2.0, 2.2 or 2.4

           -- wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.5.3.tar.gz
           -- tar -xvf 4.5.3.tar.gz
           -- ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python
           -- make
           -- make install

Configuração do Apache:

1) Crie um ambiente virtual 2) aponte para arquivos vhost 3) incluir o arquivo vhost no arquivo httpd.conf     exemplo:         - cd / usr / local / apache2 / conf /         - sudo vim httpd.conf         - adicione o local do seu arquivo vhost no final do arquivo             Minha configuração é assim: "include /home/kanagaraj/PycharmProjects/hyso_exchange/apacheconf/vhost.conf"

4) collectstatic (python manage.py collectstatice) 5) arquivo statice Pointout no arquivo vhost 6) digite assim no seu navegador: link

Nota:     exemplo para arquivos vhost vhost_local.conf, vhost_stating.conf

    
por Kanagaraj dhanapal 07.11.2016 / 14:16