ERR_EMPTY_RESPONSE by website : lxd-reverse-proxy

I was following recent blog lxd reverse proxy by simos.

As per the guide :
Visit the URL of your website with your web browser. You should see the default Apache page but When I am going to my Url from browser its says ERR_EMPTY_RESPONSE. This is happening with both apache and nginx servers.

What I am missing. I tried troubleshooting guide but no luck .
Any Idea.

Hi [Manishfoodtechs]
I use the same guide and it works well…I have over a dozen sites on different containers and they are all visible.
May need a little more information to help diagnose the problem.

I assume you have a proxy container with your virtual block setup for your website and your website/s on another container/s?

Without more details to help diagnose I would say try the obvious such as clear browser cache or try incognito mode.

My proxy virtual block config looks like this and I have one for each website and container.

Screenshot%20from%202019-11-15%2018-20-54

Also make sure these two lines shown “below” have the correct ip to you proxy container:

lxc config device add proxy myport80 proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80 proxy_protocol=true lxc config device add proxy myport443 proxy listen=tcp:0.0.0.0:443 connect=tcp:127.0.0.1:443 proxy_protocol=true

in the two lines above, make sure you replace the 127.0.0.1 with the ipv4 of your proxy container.
This routes all traffic on 80 and 443 to your proxy container and then the proxy forwards through the virtual blocks to your various lxc containers hosting the site.

Below is my remote ip config for the apache2 website…notice the ip here points to my proxy container:

1 Like

Thanks OIEIEIO . I tried this method but may be missing something. However, I found the solution which is okay for me.

  1. Made my Main host as Proxy Server and installed ningx.

  2. Used Iptables rules to listen containers / say VMs ( installed with apache2) on my Public IP:2086 by
    sudo iptables -t nat -A PREROUTING -p tcp -i eth0 -d xxx.xxx.xx.xx --dport 2086 -j DNAT --to yy.yyy.yy.yy:80 and made iptables rules persistent ( xx- public IP & yy- Internal IP)

3.I used this configuration in sudo ln -s /etc/nginx/sites-available/demo.manishfoodtechs.com

`server {

server_name site1.com www.site1.com;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://10.189.92.147:80;
}

}
server {
server_name site2.org www.site2.org;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://10.189.92.81:80;
}

}`

  1. Issued SSL certificates for my both urls.

I can also make a container as Proxy server by above solution but I believe this is not going to give me any extra advantage only if i want to use main host for something. Further, in my solution I found that the very first server i define in point 3 ( internal VM/ Container) can be reached by pointing external IP.

I am new to LXC but I am catching things quickly because of this wonderful community.

I have one performance question regarding using Iptables. I am asking it separately here.

This is solution , sorry I was making typo mistake. thanks