Welcome! Log In Create A New Profile

Advanced

nginx as backend

Mat Miller
November 03, 2012 02:20PM
Hi,

I am writing this to hopefully get some help of you gus after struggeling with this issue in a few days.

I will try to describe the issue as short as pssible.

Ok, my website runs just fine on 443 and 80 with the lastest version on nginx. (thx Igor and Nginx team!)

The problem started when I tried to put varnish (port 80) in front of Nginx (port 81).

1- Of some reason I have to start Nginx before starting varnish otherwise I get bind() to 0.0.0.0:80 failed (98: Address already in use)... (yes yes I've already checked the config out and I've changed the port to 81)

2- When i start start Nginx first and varnish after, both softwares start to run, my site works just fine on 443 (https) but using http, nginx shows /usr/local/nginx/html/index.htm instead of /var/www/domain.com/index.php

lsof -i tcp:80
nginx 1071 root 10u IPv4 4296 0t0 TCP *:www (LISTEN)
nginx 1073 www-data 10u IPv4 4296 0t0 TCP *:www (LISTEN)
nginx 1074 www-data 10u IPv4 4296 0t0 TCP *:www (LISTEN)
nginx 1075 www-data 10u IPv4 4296 0t0 TCP *:www (LISTEN)
varnishd 1093 nobody 6u IPv6 4347 0t0 TCP *:www (LISTEN)

lsof -i tcp:81
nginx 1071 root 8u IPv4 4294 0t0 TCP *:81 (LISTEN)
nginx 1073 www-data 8u IPv4 4294 0t0 TCP *:81 (LISTEN)
nginx 1074 www-data 8u IPv4 4294 0t0 TCP *:81 (LISTEN)
nginx 1075 www-data 8u IPv4 4294 0t0 TCP *:81 (LISTEN)

here is my config files

user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
include /etc/nginx/conf.d/*.conf;
port_in_redirect off;
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
default
server {
listen 81 default; ## listen for ipv4
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
server_name _;
root /var/www/domain.com;
location / {
root /var/www/defaultdir;
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
domain.com


server {
server_name .domain.com;
root /var/www/domain.com;
listen 81;
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
listen 443 ssl;
{SSL stuffs goes here}

location / {
index index.php index.html index.htm;
access_log off;
error_log off;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param HTTPS on;

}
}


I would appreciate any help I can get with this issue.

Best regards, Mat 
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx as backend

Mat Miller November 03, 2012 02:20PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 131
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready