Ive had this issue with tomcat apache in the past and always fixed it by specifying localhost as part of the listen directive - not working with NGINX on OS X. NGINX is responding to 127.0.0.1 - but localhost it just drops the connection (its not refusing the connection, just dropping it) Is there a way to fix this I have tried listen *:80, listen localhost:80 and still I cant reach it through the browser using localhost. localhost is resolvable with ping and has its entry in the hosts file.
on 2012-12-20 21:42
on 2012-12-20 22:11
On 20 December 2012 20:41, Bill Culp <bill.culp@me.com> wrote: > Ive had this issue with tomcat apache in the past and always fixed it by specifying localhost as part of the listen directive - not working with NGINX on OS X. > > NGINX is responding to 127.0.0.1 - but localhost it just drops the connection (its not refusing the connection, just dropping it)… > > Is there a way to fix this I have tried listen *:80, listen localhost:80 and still I cant reach it through the browser using localhost. > > localhost is resolvable with ping and has its entry in the hosts file. Posting your configuration would probably help people diagnose your issue more easily ... Jonathan
on 2012-12-20 22:15
lsof says NGINX is listening on localhost
nginx 3315 root 8u IPv4 0xfd9b22b8ee1eac23 0t0
TCP localhost:http (LISTEN)
When I run another web server on that port localhost works fine but not
with this NGINX config.
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log var/log/nginx/error.log info;
pid var/log/nginx/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#######################################
# Perl ImageMagick Resize
#perl_modules perl/lib;
#perl_require resize.pm;
#server {
# location / {
# root /var/www;
# if (!-f $request_filename) {
# rewrite ^(.*)(.jpg|.JPG|.gif|.GIF|.png|.PNG)$ /resize$1$2 last;
# }
# }
# location /resize {
# perl resize::handler;
# }
#}
################################ End Perl Image Resize
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 0;
keepalive_timeout 65;
#gzip on;
server {
listen localhost:80;
server_name localhost;
#charset koi8-r;
access_log var/log/nginx/host.access.log main;
location / {
root share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on
127.0.0.1:9000
#
#location ~ \.php$ {
# root share/nginx/html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME
/scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based
configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root share/nginx/html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root share/nginx/html;
# index index.html index.htm;
# }
#}
}
on 2012-12-20 23:27
Hello! On Thu, Dec 20, 2012 at 12:41:26PM -0800, Bill Culp wrote: > using localhost. > > localhost is resolvable with ping and has its entry in the hosts > file. As of now listen localhost:80; will only listen on first ipv4 address resolved from the localhost name. If you want nginx to listen on all ip addresses (likely ipv4 127.0.0.1 and ipv6 ::1 in your case), you have to list them explicitly, like this: listen 127.0.0.1:80; listen [::1]:80; Or listen on both ipv4 and ipv6 wildcard addresses, like this: listen *:80; listen [::]:80; Note well that to work with ipv6 addresses you need nginx compiled with ipv6 support. -- Maxim Dounin http://nginx.com/support.html
on 2012-12-21 02:08
Maxim, I used the listen localhost:80; listen [::]:80; And now the server responds to localhost. Not sure why this would be happening unless nginx was binding to v6 rather than v4 either way its nice to have that annoyance gone. Thanks!
on 2012-12-21 12:28
Hello! On Thu, Dec 20, 2012 at 05:07:26PM -0800, Bill Culp wrote: > either way its nice to have that annoyance gone. The problem is not that nginx binded to ipv6 - it instead binded to ipv4 only. But the tool you've used to connect to nginx only used ipv6 (or used ipv6 as first option, and didn't fallback to other addresses). > >> - not working with NGINX on OS X. > >> file. > > listen 127.0.0.1:80; > > -- > nginx@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx -- Maxim Dounin http://nginx.com/support.html
on 2012-12-21 17:09
I suspected that could the case as well I just didn't think google chrome and safari would both exhibit that behavior and the other web servers I start on the sane port aren't even ipv6 aware Sent from my iPhone
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.