Page 1 sur 1
apache derrière nginx
Posté : 28 mai 2014, 11:03
par cmsbox.fr
Bonjour à tous,
Je viens de configurer apache pour fonctionner sur le port 8080.
Devant apache, nginx reçoit les requêtes sur le port 80 et les redirige vers apache.
Tout semble bien fonctionner.
Le pb est que lorsqu'on tape monsite.com dans la barre d'adresse, on est redirigé vers monsite.com:8080
Je souhaite savoir comment faire pour que le port 8080 n'apparaisse pas dans l'url.
Est-on condamné à afficher des ports dans l'url lorsqu'on utilise nginx avec apache?
En vous remerciant pour vos réponses.
Re: apache derrière nginx
Posté : 28 mai 2014, 11:22
par Sékiltoyai
Bonjour,
C'est que tu as mal configuré !

Par rediriger, qu'as-tu fait ? Peux-tu montrer la conf nginx correspond à ce que tu as fait ?
Cordialement
Re: apache derrière nginx
Posté : 28 mai 2014, 12:42
par cmsbox.fr
Bonjour,
Merci bcp pour la contribution.
Voici ma configuration nginx. J'utilise également php5-fpm.
Code : Tout sélectionner
server {
listen 80;
root /var/www/monsite.com/htdocs;
index index.php index.html index.htm;
server_name monsite.com;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/monsite.com/htdocs;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Re: apache derrière nginx
Posté : 28 mai 2014, 14:17
par Sékiltoyai
Bonjour,
Ce que je vois c'est une conf nginx qui envoie ses requêtes à php5-fpm.
Où intervient apache dans tout ça ?
Cordialement
Re: apache derrière nginx
Posté : 28 mai 2014, 15:03
par cmsbox.fr
Je pensais que php5-fpm était une extension d'apache.
J'ai changé en mettant la configuration suivante mais même pb: monsite.com me redirige vers monsite.com:8080 avec le port visible.
Code : Tout sélectionner
server {
listen 80
root /var/www/monsite.com/htdocs;
server_name monsite.com www.monsite.com;
index index.php index.html index.htm;
access_log /var/www/monsite.com/logs/nginx_access.log;
error_log /var/www/monsite.com/logs/nginx_error.log;
location / {
# this is the location block for the document root of this vhost
}
location ~ \.php {
# this block will catch any requests with a .php extension
# normally in this block data would be passed to a FastCGI process
# these two lines tell Apache the actual IP of the client being forwarded
# Apache requires mod_proxy (http://bit.ly/mod_proxy) for these to work
# Most Apache 2.0+ servers have mod_proxy configured already
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
# this next line adds the Host header so that apache knows which vHost to serve
# the $host variable is automatically set to the hostname Nginx is responding to
proxy_set_header Host $host;
# And now we pass back to apache
# if you're using a side-by-side configuration the IP can be changed to
# apache's bound IP at port 80 such as http://192.170.2.1:80
proxy_pass http://127.0.0.1:8080;
}
# if you don't like seeing all the errors for missing favicon.ico in root
location = /favicon.ico { access_log off; log_not_found off; }
# if you don't like seeing errors for a missing robots.txt in root
location = /robots.txt { access_log off; log_not_found off; }
# this will prevent files like .htaccess .htpassword .secret etc from being served
# You can remove the log directives if you wish to
# log any attempts at a client trying to access a hidden file
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Re: apache derrière nginx
Posté : 28 mai 2014, 15:15
par Sékiltoyai
Je pensais que php5-fpm était une extension d'apache.
J'ai changé en mettant la configuration suivante mais même pb: monsite.com me redirige vers monsite.com:8080 avec le port visible.
Non, php-fpm est un démon indépendant qui n'a rien à voir avec apache. Tu peux très bien déployer nginx + php5-fpm seul et désinstaller apache (cela correspond à la configuration précédente).
Le problème ici est le code ou la configuration du site.
Cordialement.
Re: apache derrière nginx
Posté : 28 mai 2014, 15:31
par cmsbox.fr
le pb est résolu. il venait d'ailleurs et n'avait rien à voir avec apache/nginx.
La remarque sur php5-fpm a été très utile, merci beaucoup.