V
V
vasjapupkin3192014-06-20 02:05:09
Nginx
vasjapupkin319, 2014-06-20 02:05:09

Setting up apache + nginx for 2 domains on the same IP?

Hi all!
Please tell me how to set up a bunch of apache (back-end) + nginx (front-end) for two domains on the same ip.
I read several articles, guides, and how to make a bunch and how to make several domains on one IP, but when I tried to do something, it didn’t work (the articles were lobos on setting up apache + nginx, or on 2 domains on one IP).
Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan, 2014-06-20
@0neS

I don't understand what is the problem?

http {
  ...
  upstream apache {
    server 127.0.0.1:8080;
  }

  server {
    listen 80 default_server;
    server_name 123.456.789.012;
    location / {
      proxy_pass http://apache;
    }
  }

  server {
    listen 80;
    server_name site1.ru;
    ...
    location / {
      proxy_pass http://apache;
    }
  }

  server {
    listen 80;
    server_name site2.ru;
    ...
    location / {
      proxy_pass http://apache;
    }
  }
}

C
Cool Admin, 2014-06-20
@ifaustrue

Or an option for SSL

server {

        listen   443 default;
        server_name example.com;

        ssl on;
        ssl_certificate /etc/nginx/ssl/example.com/server.crt;
        ssl_certificate_key /etc/nginx/ssl/example.com/server.key;
        location / {
      proxy_pass http://apache;
    }
}
server {

        listen   443;
        server_name vk.com;

        ssl on;
        ssl_certificate /etc/nginx/ssl/vk.com/server.crt;
        ssl_certificate_key /etc/nginx/ssl/vk.com/server.key;
        location / {
      proxy_pass http://apache_vk;
    }
}

V
vasjapupkin319, 2014-06-21
@vasjapupkin319

That is, for two sites, you can do 1 config, right?
Apache too?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question