Trick to running Nginx with Vagrant?

103 views
Skip to first unread message

French Fry

unread,
Oct 30, 2017, 8:32:25 PM10/30/17
to Vagrant
I've tried a number of configurations , i.e. forwarding ports (guest and host) as well as a private network.  Nginx listens on port 80.  The Nginx server can be seen if I have guest: 80 and host: 8080.   When I start up the web server it runs fine but Nginx seems to have no recognition of it.  Without the private network they are both on 0.0.0.0 or 127.0.0.1 (as 0.0.0.0 resolves too anyway) as defined in the etc/host. With the private network, same deal.

I'm trying to rule the possibility of something I might be doing wrong in Vagrant. Obviously I'm trying to do this via TCP , not sockets.  If anyone knows ANYTHING to try I'd be happy to hear.

Thanks
FF

Alvaro Miranda Aguilera

unread,
Oct 31, 2017, 5:52:18 AM10/31/17
to vagra...@googlegroups.com
can you share a github repo of the Vagrantfile and the scripts?

Can be se-linux can be iptables, can be listen, can be virtualhost, etc.

so if you what you have, I can just vagrant up and test.

alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/e4be3198-eb93-4067-9ab4-fe6529135c64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

French Fry

unread,
Oct 31, 2017, 3:00:41 PM10/31/17
to Vagrant
Alright, maybe I'll need to up the scripts.

For the iptables , all I can get is this:
vagrant@vagrant:~$ sudo iptables --list-rules
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
vagrant@vagrant:~$

Re selinux. I tried 
getenforce and sestatus both return command not found 
There is a selinux conf file, only two lines un-commented 
module-store = direct
expand-check=0

I don't believe I need VirtualHosts because I only have one site.

Right now I have Niginx on guest 80, I can get the Nginx page at 8080
Web with Thin is running on 3000, can get at 4567.  Putting aside possible problems in my conf file or vagrantfile, - from the tcp side if they are both running on 127.0.0.1 should Niginx be able to see the app server?

Thanks
FF





On Tuesday, October 31, 2017 at 3:52:18 AM UTC-6, Alvaro Miranda Aguilera wrote:
can you share a github repo of the Vagrantfile and the scripts?

Can be se-linux can be iptables, can be listen, can be virtualhost, etc.

so if you what you have, I can just vagrant up and test.

alvaro.
On Tue, Oct 31, 2017 at 1:32 AM, French Fry <samb...@gmail.com> wrote:
I've tried a number of configurations , i.e. forwarding ports (guest and host) as well as a private network.  Nginx listens on port 80.  The Nginx server can be seen if I have guest: 80 and host: 8080.   When I start up the web server it runs fine but Nginx seems to have no recognition of it.  Without the private network they are both on 0.0.0.0 or 127.0.0.1 (as 0.0.0.0 resolves too anyway) as defined in the etc/host. With the private network, same deal.

I'm trying to rule the possibility of something I might be doing wrong in Vagrant. Obviously I'm trying to do this via TCP , not sockets.  If anyone knows ANYTHING to try I'd be happy to hear.

Thanks
FF

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Peter Folk

unread,
Nov 1, 2017, 3:02:36 AM11/1/17
to vagra...@googlegroups.com
not sure, what exactly your problem is, but I have nginx just working fine on Ubuntu 16.04 in Vagrant

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/9448d48e-b71b-4aa7-a39d-2f85f382135b%40googlegroups.com.

French Fry

unread,
Nov 1, 2017, 12:04:35 PM11/1/17
to Vagrant

I know it is not uncommon that Rails/ Ruby web servers generally only will work on 0.0.0.0:3000 (in development).  So that is what I run my dev server on and host is port 4567.  Yet if I try say, 127.0.01 , server will connect but I can't get the page. 

Ngnix works, but is only seeing what is on it's own ports, in other words, 80 is guest, 8080 is host.  If I do a localhost:8080 Niginx will go to the correct files it's just doesn't respond to any other port, even with server set to _: in my conf file.

One thing maybe weird, nmap shows port 3000/tcp but says ppp is the service.

Alvaro Miranda Aguilera

unread,
Nov 1, 2017, 4:11:36 PM11/1/17
to vagra...@googlegroups.com
can you share the output of (from the guest)

netstat -anp | grep -i listen


To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/80a72ce2-dce5-4daa-9d8d-ba2c05022794%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

French Fry

unread,
Nov 1, 2017, 6:10:10 PM11/1/17
to Vagrant
Alvaro, here is the Netstat (-anp | grep -i listen). 

unix  2      [ ACC ]     STREAM     LISTENING     20454    2767/systemd        /run/user/1000/systemd/private
unix  
2      [ ACC ]     SEQPACKET  LISTENING     9974     -                   /run/udev/control
unix  
2      [ ACC ]     STREAM     LISTENING     17042    -                   /var/run/postgresql/.s.PGSQL.5432
unix  
2      [ ACC ]     STREAM     LISTENING     9780     -                   /run/systemd/private
unix  
2      [ ACC ]     STREAM     LISTENING     9790     -                   /run/systemd/fsck.progress
unix  
2      [ ACC ]     STREAM     LISTENING     9791     -                   /run/systemd/journal/stdout
unix  
2      [ ACC ]     STREAM     LISTENING     9794     -                   /run/lvm/lvmpolld.socket
unix  
2      [ ACC ]     STREAM     LISTENING     9838     -                   /run/lvm/lvmetad.socket
unix  
2      [ ACC ]     STREAM     LISTENING     12994    -                   /run/snapd.socket
unix  
2      [ ACC ]     STREAM     LISTENING     12997    -                   /var/lib/lxd/unix.socket
unix  
2      [ ACC ]     STREAM     LISTENING     15348    -                   @ISCSIADM_ABSTRACT_NAMESPACE
unix  
2      [ ACC ]     STREAM     LISTENING     12993    -                   /run/rpcbind.sock
unix  
2      [ ACC ]     STREAM     LISTENING     12995    -                   /run/snapd-snap.socket
unix  
2      [ ACC ]     STREAM     LISTENING     12996    -                   /run/uuidd/request
unix  
2      [ ACC ]     STREAM     LISTENING     13000    -                   /var/run/dbus/system_bus_socket
unix  
2      [ ACC ]     STREAM     LISTENING     13001    -                   /run/acpid.socket


This is what I have of relevance in my vagrant file

config.vm.network "forwarded_port", guest: 80, host: 8080, protocol: "tcp", host_ip: "127.0.0.1"
config
.vm.network "forwarded_port", guest: 80, host: 8080, protocol: "udp", host_ip: "127.0.0.1"
config
.vm.network "forwarded_port", guest: 8000, host: 4567, protocol: "tcp", host_ip: "127.0.0.1"
config
.vm.network "forwarded_port", guest: 8000, host: 4567, protocol: "udp", host_ip: "127.0.0.1"


Nginx is on 80 / 8080 and Ruby on 8000 / 4567.  Though these don't show up in this particular netstat.  Just going to mention though, using either localhost:8080 or 127.0.0.1 I can see my nginx.conf file working, but once I go to the app, nothing.  Maybe I should try to make it work with sockets instead. 



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 1, 2017, 6:20:45 PM11/1/17
to vagra...@googlegroups.com
uhm there is nothing listening

can you run this as sudo and confim this is from the guest?

sudo netstat -anp 

if too long, perhaps a gist (gist.github.com) will do the trick.


To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a439519a-3699-4781-a0f9-8e4ab233c3f8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

French Fry

unread,
Nov 1, 2017, 6:37:02 PM11/1/17
to Vagrant

Joaquin Menchaca

unread,
Nov 10, 2017, 2:17:39 PM11/10/17
to Vagrant
There are so many levels of troubleshooting.  Can you access service in the guest as localhost?  Nginx binded to 0.0.0.0?  Was nginx able to bind to port 80? (check logs)  On the host, was the Virtual system able to bind 8080? (nothing else ocupying that slot)?  Firewall on guest or host blocking it off?

You might want to consider using private IP address, then you can access it directly from the host, vagrant/virtualbox automatically creates virtual network infrastructure so you can access it, then you don't have to do NAT port mapping.

French Fry

unread,
Nov 10, 2017, 2:59:03 PM11/10/17
to Vagrant
I should have updated the post, my apologies.  I got it sorted out.  My problems were, and don't laugh, I didn't realize that the web app and server runs under Nginx. So while Nginx was on 80/8080, I expected it to work for me while the app was on 3000/4567.  Plus a poorly written conf file, which wasn't helping.
Reply all
Reply to author
Forward
0 new messages