I have Valet installed on my iMac, and I'm hoping to be able to access it on the local network from my iPad. I only need to run one site from it (I'm making a label printer "bridge" since Zebra doesn't care about SSL). When I go to the iMac's IP address in my browser, I get the basic Valet - Not Found page. Is there some way to tell Valet to serve whatever site as the "default" so I can access it from the iPad? Thanks in advance for any help.
Thank you for that. I didn't even check PRs, just issues. I did not see any issues that match my problem, but I may have missed them...
I'll check that PR and give it a test. 👍
Ya, it's almost the perfect use-case for it.
You can also use valet share.
On Thu, Sep 21, 2017 at 8:18 PM Chris Brown notifications@github.com
wrote:
Ya, it's almost the perfect use-case for it.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/laravel/valet/issues/440#issuecomment-331316070, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEH3bOTdOxGkKJRZ3NWCaMqDbCm8l-TFks5skvy5gaJpZM4PgAUU
.
valet share does not work in this case, because I'm having to rely on things "Just Working™️". If someone restarts the Mac, then the server needs to just automatically come back up. Unless you have some way for valet share to automatically run on reboot, and get the same ngrok URL...
+1 need this
so i cannot share using my local area ip to share using valet? I need to connect to internet? I guess this needs to be fixed :)
Use #439 for that.
@drbyte you mean we change directly on file? But that is not merged and can get removed once we update isn't it?
Yes, that is correct.
But the changes are easy to make, until Valet is updated to include it.
Your files are in: ~/.composer/vendor/laravel/valet
Hello there.
I found out a way to enable Local Network Access in latest Valet.
Edit $HOME/.config/valet/config.json
add a default entry.
Example:
{
"paths": [
"/Users/myusername/.config/valet/Sites"
],
"default": "/Users/myusername/.config/valet/Sites/atlas",
"tld": "test"
}
Edit /usr/local/etc/nginx/valet/valet.conf
Change listen 127.0.0.1:80 default_server; to the below
listen 80 default_server;
Try it out using your ip on your own browser.
If it works, it should work on any other browser in your network.
Hello there.
I found out a way to enable Local Network Access in latest Valet.Edit
$HOME/.config/valet/config.jsonadd a default entry.
Example:
{ "paths": [ "/Users/myusername/.config/valet/Sites" ], "default": "/Users/myusername/.config/valet/Sites/atlas", "tld": "test" }Edit
/usr/local/etc/nginx/valet/valet.confChange
listen 127.0.0.1:80 default_server;to the belowlisten 80 default_server;Try it out using your ip on your own browser.
If it works, it should work on any other browser in your network.
I have done all of the above steps but I can not access the site using my IP/blog.test
only from blog.test
So local network access does not work...
Id there anything else I can do?
@mkotsovoulou is ur ip port forwarded? can u access using localhost/blog.test?
@mkotsovoulou don't forget to restart nginx. or do valet restart to be sure.
Is there some smart way to access all websites instead of just the one in "default"? It would be really nice if there was valet default that would change that config value. But i guess simple script will do.
The problem is that Valet checks for the hostname from the $_SERVER['HTTP_HOST'] value, and in this case it's the IP address, so not a valid hostname.
I added this bit of code in the file $HOME/.composer/vendor/laravel/valet/server.php after the loading of $valetConfig :
$valetConfig = json_decode(
file_get_contents(VALET_HOME_PATH.'/config.json'), true
);
/**
* If the HTTP_HOST is an IP address, check the start of the REQUEST_URI for a
* valid hostname, extract and use it as the effective HTTP_HOST in place
* of the IP. It enables the use of Valet in a local network.
*/
if (preg_match('/^([0-9]+\.){3}[0-9]+$/', $_SERVER['HTTP_HOST'])) {
$uri = ltrim($_SERVER['REQUEST_URI'], '/');
if (preg_match('/^[-.0-9a-zA-Z]+\.'. $valetConfig['tld'] .'/', $uri, $matches)) {
$host = $matches[0];
$_SERVER['HTTP_HOST'] = $host;
$_SERVER['REQUEST_URI'] = str_replace($host, '', $uri);
}
}
It should work immediately if you've already removed 127.0.0.1 from the nginx config as said in the previous comments.
Most helpful comment
valet sharedoes not work in this case, because I'm having to rely on things "Just Working™️". If someone restarts the Mac, then the server needs to just automatically come back up. Unless you have some way forvalet shareto automatically run on reboot, and get the same ngrok URL...