E
E
evil0o2014-05-21 17:52:07
Apache HTTP Server
evil0o, 2014-05-21 17:52:07

How to configure nginix and apache if there are several sites?

The problem is that the first VirtualHost in Apache always opens at any address, when nginix is ​​disabled, everything works fine
nginix.conf

user  apache;
worker_processes  150;

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


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
  upstream backend {
    server 127.0.0.1:8080;
  }
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

  server {
    listen 80;
    server_name _;
    client_max_body_size 101M;
    location / {
      proxy_pass http://127.0.0.1:8080/;
    }
     location ~* \.(jpg|jpeg|gif|png|ico|css|bmp|swf|js)$ {
      root /home/site1.ru/www;
    }
    location ~ /\.ht {
                        deny  all;
                }

  }

  include /etc/nginx/conf.d/*.conf;
}

httpd.conf It seems that everything that is important is copied here
Listen 8080
NameVirtualHost 127.0.0.1:8080

<VirtualHost 127.0.0.1:8080>
  DocumentRoot "/home/site1.ru/www"
  ServerName "site1.ru"
  ServerAlias www.site1.ru site1.ru
</VirtualHost>

<VirtualHost 127.0.0.1:8080> 
   ServerName default
   DocumentRoot /var/www/html
</VirtualHost>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zysyl, 2014-05-21
@evil0o

you need to proxy the headers as well. In the root location, you need to add
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question