Welcome! Log In Create A New Profile

Advanced

configuration nginx server block [virtual host] with Ipv6.

Posted by Vanhels 
Hi, I have installed nginx + php-fpm (php5.4 / php5.6), i'm trying to set
everything up for ipv6 in Centos 7.3, install from official nginx repo:

[/etc/nginx/nginx.conf]:

user nginx;
worker_processes 1;
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;
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;
include /etc/nginx/conf.d/*.conf;
}

[/etc/nginx/conf.d/default.conf]:
server {
listen [::]:80;

server_name localhost;

location ~ \.php$ {
root html;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
fastcgi_pass [::]:9056;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}

location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}


[domain1.conf]:

# create new
server {

listen [::]:80;

root /home/domain1/public_html;
index index.php index.html index.htm;

server_name domain1 www.domain1;

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass [::]:9056;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

}
}

[subdomain.domain1.conf]:

# create new
server {

listen [::]:80;

root /home/domain1/public_html/subdomain;
index index.php index.html index.htm;

server_name subdomain.domain1 www.subdomain.domain1;

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass [::]:9056;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

}
}

If in [domain.conf] change to:

Listen 80;
fastcgi_pass 127.0.0.1:9056;

It works perfect, because this behavior I'm doing wrong,

thank you in advance for your answers,

Wilmer.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,272864,272864#msg-272864

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Thu, Mar 09, 2017 at 03:10:13PM -0500, Vanhels wrote:

Hi there,

> Hi, I have installed nginx + php-fpm (php5.4 / php5.6), i'm trying to set
> everything up for ipv6 in Centos 7.3, install from official nginx repo:

What part fails for you?

Does nginx listen on the IPv6 port? Does the client connect to nginx? Does
the fastcgi server listen on the IPv6 port? Does nginx connect to the
fastcgi server?

You suggest that something is bad with

> listen [::]:80;
> fastcgi_pass [::]:9056;

but is good with

> Listen 80;
> fastcgi_pass 127.0.0.1:9056;

One difference there is that your fastcgi_pass in IPv4 connects to an
address:port, while in IPv6 it does not.

I would guess that using [::1]:9056 might have a chance of helping.

But only if you can already fetch a file from nginx on IPv6 when fastcgi
is not involved.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Thanks for your answer, I'll specify it better:

Config Work Fine:

[domain1.conf]:

server {
listen [::]:80;
root /home/domain1/public_html;
index index.php index.html index.htm;
server_name domain1 www.domain1;
location ~ \.php$ {
fastcgi_pass [::]:9056;
}
}

[subdomain.domain1.conf]:

server {
listen 80;
root /home/domain1/public_html/subdomain;
index index.php index.html index.htm;
server_name subdomain.domain1 www.subdomain.domain1;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9056;
}
}

Config No Work :


[domain1.conf]:

server {
listen [::]:80;
root /home/domain1/public_html;
index index.php index.html index.htm;
server_name domain1 www.domain1;
location ~ \.php$ {
fastcgi_pass [::]:9056;
}
}

[subdomain.domain1.conf]:

server {
listen [::]:80;
root /home/domain1/public_html/subdomain;
index index.php index.html index.htm;
server_name subdomain.domain1 www.subdomain.domain1;
location ~ \.php$ {
fastcgi_pass [::]:9056;
}
}

The error happens when Listen and fastcgi_pass have the same port address in
both domains,


Thks,

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,272864,272867#msg-272867

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Thu, Mar 09, 2017 at 06:06:05PM -0500, Vanhels wrote:

Hi there,

> The error happens when Listen and fastcgi_pass have the same port address in
> both domains,

What's the error?

What do you do / what do you see / what do you want to see instead?

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
The websites pages do not load, not open, and write anything in te log,

Thks,

Wilmer.


El 10/3/2017 21:00, "Francis Daly" <[email protected]> escribió:

On Thu, Mar 09, 2017 at 06:06:05PM -0500, Vanhels wrote:

Hi there,

> The error happens when Listen and fastcgi_pass have the same port address
in
> both domains,

What's the error?

What do you do / what do you see / what do you want to see instead?

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Fri, Mar 10, 2017 at 09:06:03PM -0400, Wilmer Arambula wrote:

Hi there,

> The websites pages do not load, not open, and write anything in te log,

What response do you get when you do something like

curl -v -g -H Host:domain1.com 'http://[::1]:80/'

on the server itself?

"Nothing in the log" usually means that the request is not getting to
nginx at all.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login