P
P
Pavel2015-09-02 00:50:39
Apache HTTP Server
Pavel, 2015-09-02 00:50:39

How to set up nginx as a reverse proxy?

Hello everybody.
Help, please, to solve the problem.
Input data:
1) there is a host system with openvz raised
2) 2 containers (frontend and backend) are created in openvz with IPs 192.168.1.101 and 192.168.1.102, respectively
3) nginx is running on the frontend virtual machine.
Task: set up the nginx config as a reverse proxy to the backend virtual machine.
I read a lot of information, but, unfortunately, I did not understand how to set it up.
Can someone provide an example nginx configuration?
PS You also need to create an upstream in the config, in which to make a proxy pass on the backend.
Thanks in advance for your help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2015-09-02
@pavel_i

I made this config ngunx.conf. But I feel like it's not quite right.

# пользователь, от которого запускается процесс
user www-data;
# кол-во рабочих процессов. Обычно равно кол-ву ядер на машине
worker_processes  2;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  2;
    tcp_nodelay        on;

    gzip  on;
    gzip_comp_level 3;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

As I understand it, you still need to configure proxy.conf correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question