0

I have three LXC containers (CN1, CN2, CN3). They each run their own Apache instance and have their own networking, so each container has their own private IP.

I set up all containers to listen on the private IP only for Apache. I also set up Nginx to act as a proxy from the host machine to direct any traffic based on the domain requested.

So, I have web1 -> CN1 (10.0.3.2), web2 -> CN2 (10.0.3.3), web3 -> CN3 (10.0.3.4).

When I go to web1, it shows the right page. When I go to web2, it shows the right page. When I go to web3, however, it shows web2's page.

Here's my Nginx server configs:

web2

server { server_name web2; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://10.0.3.3:802; } }

web3

server { server_name web3; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://10.0.3.4:804; } }

Apache's running on web3 and I get get the page when I telnet to it from the host machine itself:

root@SKYNet:/etc/nginx/sites-available# telnet 10.0.3.4 804 Trying 10.0.3.4... Connected to 10.0.3.4. Escape character is '^]'. GET / HTTP/1.1 Host: web3 HTTP/1.1 200 OK Date: Sun, 26 May 2013 17:00:27 GMT Server: Apache/2.2.22 (Ubuntu) Last-Modified: Sun, 26 May 2013 16:27:58 GMT ETag: "20457c-b1-4dda183dd360e" Accept-Ranges: bytes Content-Length: 177 Vary: Accept-Encoding Content-Type: text/html X-Pad: avoid browser bug 

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

I can also ping it from my home machine, and also from external sites that allow you to ping websites. I even had a friend test it and it displayed the same thing (web2's index file instead of its own).

1 Answer 1

1

I forgot to enable the Nginx config.

Assuming your sites-available configs are stored in /etc/nginx/sites-available/ and Nginx reads from /etc/nginx/sites-enabled/ to see what servers to handle, do this:

ln -s /etc/nginx/sites-available/server_config /etc/nginx/sites-enabled/server_config 

Then restart or reload Nginx.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.