A
A
Alexander2018-02-08 18:17:53
Nginx
Alexander, 2018-02-08 18:17:53

How to set up a server. So that one Nginx docker container serves several applications (php/python/etc)?

Good day gentlemen!
I'm not so strong in nginx and I just understand Docker.
What is:
1. One VPS droplet on DigitalOcean
2. One domain: mydomen.com
3. One Nginx container
4. Many applications: php, python, node.js and others
Purpose: to run appropriate php applications on php1.mydomen.com , php2.mydomen.com and so on, python1.mydomen.com, python2.mydomen.com and so on. So that all this is served by one nginx in conjunction with other layers (* if necessary) already in other application containers.
Perhaps a different formulation of the problem and its solution :)
Mb who will direct, a guide or a good link.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Twelfth Doctor, 2018-02-08
@alexTitakoff

What's the problem? Expand the container with Nginx and applications, write in the Nginx configuration file

# Для приложения на PHP
server {
server_name php1.mydomen.com;
location ~* \.php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass IP_OF_CONTAINER:FPM_PORT; # подключаем сокет php-fpm
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

#Для python приложения (uwsgi)
server {
server_name python1.mydomen.com
location / {
        uwsgi_pass  IP_OF_CONTAINER:UWSGI_PORT;
        include     /path/to/your/mysite/uwsgi_params; # the uwsgi_params file you installed
    }
}

The backend of each application (php-fpm or uwsgi) runs in a separate container and listens on its own port.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question