J'ai un serveur Digitalocean avec ubuntu linux, nginx 1.4.6 (fonctionnant sur le port 80), varnish 3.0.5 (fonctionnant sur le port 8080, ensemble) J'ai deux domaines, disons siteA.com et siteB.com. Dans default.conf de nginx j'ai configuré pour que la porte d'entrée (80) utilise le dossier siteA comme racine, le code est :
server {
listen *:8080 default_server;
root /home/sitea;
index index.html index.htm index.php;
server_name IP_domain_siteA;
location / {
autoindex on;
autoindex_exact_size off;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri =404;
expires off;
fastcgi_read_timeout 900s;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
mais je veux que le SiteB utilise le même port pour l'accès des deux domaines au même serveur. Ainsi, lorsque j'accède au site :
siteA.com => carry my server folder:
/home/siteA/index.php
siteB.com => carry the same server folder (same ip as well):
/home/siteB/index.html
Comment je fais ? J'ai déjà tout essayé, même d'inclure ces lignes de backend dans default.VCL (configuration de varnish).
backend siteA{
.host = "sitea.com";
.port = "8080";
}
backend siteB{
.host = "siteb.com";
.port = "8080";
}
sub vcl_recv {
if (req.http.host == "sitea.com") {
#You will need the following line only if your backend has multiple virtual host names
set req.http.host = "sitea.com";
set req.backend = siteA;
return (lookup);
}
if (req.http.host == "siteb.com") {
#You will need the following line only if your backend has multiple virtual host names
set req.http.host = "siteb.com";
set req.backend = siteB;
return (lookup);
}
}
Il n'est pas résolu, il me renvoie l'erreur :
BACKEND HOST "siteB.com" : se résout en plusieurs adresses IPv4. Seule une seule adresse est autorisée.
j'utilise déjà hôtes virtuels pour d'autres dossiers avec nginx mais il n'est possible de changer que les PORTS, la ligne server_name dirigée vers le domaineA ou le domaineB, ne fonctionne pas.... car c'est la même IP.
Que puis-je faire ? Quelqu'un a-t-il des suggestions ? Merci.
EDIT 1 :
La configuration de nginx pour les deux sites est ici (siteA) :
server {
listen *:8080 default_server;
root /var/www/public/sitea;
try_files $uri $uri/ @handler;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
##domain address 1 of server...
server_name www.sitea.com.br sitea.com.br;
#location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
#}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
proxy_read_timeout 150;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 120;
include fastcgi_params;
}
}
l'autre site (siteB) :
server {
listen 8090;
client_max_body_size 20M;
root /var/www/public/siteb;
index index.html index.htm index.php;
##domain address 2 of server...
server_name www.siteb.com.br siteb.com.br;
location / {
autoindex on;
try_files $uri $uri/ /index.php?q=$request_uri;
autoindex_exact_size off;
proxy_pass http://localhost:8080;
}
location ~ \.php$ {
#try_files $uri =404;
expires off;
fastcgi_read_timeout 900s;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}