Vagrant share's funky url stuck on the " Welcome to Nginx" page

937 views
Skip to first unread message

Jeanmichel Cote

unread,
Mar 28, 2014, 4:12:47 AM3/28/14
to vagra...@googlegroups.com
Hi,

i just set myself a nice vagrant local development of a website that is online at the moment. I've forwarded ports 8080 on host to 80 on guest, tweaked my host's hosts file adding 127.0.0.1 mysite.com and i configured my nginx accordingly so instead of visiting localhost:8080, i go to mysite.com:8080 and the site is right up. Good.

So i thought, great, now i want to show the client some modifications i just made to his site. Vagrant share then gives me a funky url which i go visit in a browser.

The thing is that even though it worked just fine on mysite.com:8080, by using vagrant share's url it just throws the "Welcome to Nginx!" page, as if it couldnt read my mysite file in /etc/nginx/sites-enabled/mysite.

I hope i made myself clear enough so that it ring someone's bell. If you have any info about this, it would help a lot.

Thanks!

Terrance Shepherd

unread,
Mar 28, 2014, 7:02:02 AM3/28/14
to vagra...@googlegroups.com

This is probably a problem with nginx and you code then vagrant.

From here my guess is that your nginx config is only set up to respond with your code if you access it from mysite.com  and so changing your nginx config by removing server line will probably fix this.

--
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.
For more options, visit https://groups.google.com/d/optout.

Jeanmichel Cote

unread,
Mar 28, 2014, 8:05:32 AM3/28/14
to vagra...@googlegroups.com
Well, thanks for answering. You may be right. But i'm not sure about that yet.
Here's my nginx code:

   server {
        listen 80;
        server_name mysite.com www.mysite.com;
        root /vagrant/public;  
        rails_env development;
        passenger_enabled on;
        client_max_body_size 100M;
        if ($host ~* www\.(.*)) {
            set $host_without_www $1;
            rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo'
        }
    }

Now i know its best not to use if statements but i'm on a closed circuit mode running that particular code only in my VM server.
Otherwise the
 return 301 $scheme://mysite.com$request_uri;
breaks entirely the access by trying to redirect to the actual live site, which means that i dont know how to make that statement redirect with a port number. I tried
return 301 $scheme://mysite.com:8080$request_uri;
but its bad redirection.

So i'll keep on digging...

Alvaro Miranda Aguilera

unread,
Mar 28, 2014, 8:19:38 AM3/28/14
to vagra...@googlegroups.com
what happen if you put

        server_name *

Jeanmichel Cote

unread,
Mar 28, 2014, 8:55:57 AM3/28/14
to vagra...@googlegroups.com
If i do
server_name *;

nginx server wont restart.
Which means "sudo service nginx restart" wont work.

Nice try ;)

Terrance Shepherd

unread,
Mar 28, 2014, 9:04:02 AM3/28/14
to vagra...@googlegroups.com
So it will actually work but it collides with the file /etc/nginx/sites-enabled/000-default which is what returns the "Welcome to Nginx page" you would need to disable the default site first. 

You can disable the default site by running:
nginx_dissite 000-default

If that still does not work you can add *.vagrantshare.com to the server_name parameter

*note the 000-default might be different in your environment.

Jeanmichel Cote

unread,
Mar 28, 2014, 9:08:58 AM3/28/14
to vagra...@googlegroups.com
Yeah, i tried already the vagrantshare.com option, i even tried to add the whole temporary funky share url. But i didnt help.

And your right about the default file. I dont know why but accessed from the web, my nginx serves the default file rather than the mysite file.

I'm gonna go ahead an try disabling the default site, as you suggest.

I'll be back later today...

thanks!

Armon Dadgar

unread,
Mar 28, 2014, 1:45:58 PM3/28/14
to vagra...@googlegroups.com, Jeanmichel Cote
This is a virtual host issue. You’ve configured nginx to only serve specific
virtual hosts using your site, and the rest are handled by the default site.

With vagrant share, the virtual host sent is actually that funky name, so visiting
http://funky-panda-1234.vagrantshare.com” is actually going to to use the “funky-panda-1234”
as the vhost.

Hope that helps!

Best Regards,
Armon Dadgar

Jeanmichel Cote

unread,
Mar 28, 2014, 4:17:10 PM3/28/14
to vagra...@googlegroups.com, Jeanmichel Cote
If it helps??? You bet it does. Thanks plenty.

So what i did is that i
  • "vagrant up", then "vagrant share" so that i get that "funky-sharename".
  • Then i "cp" my nginx "mysite" file in the "sites-available" directory and named it "funky-sharename".
  • Inside i changed "server_name mysite" to "server_name funky-sharename funky-sharename.vagrantshare.com"
  • and "ln -s" it to the "sites-enabled" directory.
Voila. Pretty much straightforward.

:))
Reply all
Reply to author
Forward
0 new messages