Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx not serving from localhost but will serve from 127.0.0.1 #113

Closed
anthonybrown opened this issue Nov 2, 2015 · 7 comments
Closed

Comments

@anthonybrown
Copy link

I use brew-services and love it but recently I noticed my nginx server is no longer serving files from localhost:8080

It will serve from 127.0.0.1:8080

Any ideas if this has something to do with running everything from brew-services?

I've installed all my software with brew PHP56, mysql, redis, memcached etc and things were working like expected until a couple of brew upgrade ago.

@anthonybrown
Copy link
Author

Here is the gist

@plessbd
Copy link

plessbd commented Nov 2, 2015

What about your nginx.conf and any enabled sites?
also please provide the output of sudo lsof -i TCP -Pn | grep nginx

I had this happen before and it was because nginx is not listening on ipv4 but only on ipv6

my server directive looks this this:

server {
    listen [::]:80;
    return 301 https://$server_name$request_uri;
    include conf.d/restrictions.conf;
}

@anthonybrown
Copy link
Author

@plessbd I added the [::] before the port and it's serving from localhost now.
👍

@anthonybrown
Copy link
Author

@plessbd how would you serve up PHP applications?
I'd love to be able to not have to use localhost:8080 for all my nginx
projects and just localhost for my Apache/PHP/MySQL projects?

@plessbd
Copy link

plessbd commented Nov 2, 2015

@anthonybrown
If you want more help I can email you (since github as far as I know doesnt let direct communication) and this is a bit off topic

I use a combination of dnsmasq and phpfpm
you can see my setup script here https://github.com/plessbd/setup

I then have nginx have a server_name
here is an example of my config for adminer

server {
    listen [::]:80;
    server_name adminer.ben.dev;
    return 301 https://$server_name$request_uri;
    include conf.d/restrictions.conf;
}

server {
    listen       [::]:443 http2 ssl;
    include conf.d/star.ben.dev.ssl.conf;
    include conf.d/restrictions.conf;

    server_name adminer.ben.dev;
    root    /usr/local/share/adminer;

    access_log  /usr/local/etc/nginx/logs/adminer.access.log    json;
    error_log       /usr/local/etc/nginx/logs/adminer.error.log debug;

    location / {
        # for php
        include  /usr/local/etc/nginx/conf.d/php-fpm;
    }
}

@plessbd plessbd mentioned this issue Nov 2, 2015
@anthonybrown
Copy link
Author

@plessbd Thanks, I'll take you up on that offer when I get a little more time, thanks much appreciated!

@lock
Copy link

lock bot commented Apr 9, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Apr 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants