Closed matthijs110 closed 6 years ago
I briefly experienced a similar issue going the other direction.. from secure to unsecure.. restarted valet and it was fine. Might be a caching issue with caddy perhaps?
Restarting Valet does not work unfortunately. Only valet unsecure
.
also having this issue
I'm also having the same problem :(
+1 for this issue , can't figure it out. [ Valet 2 ]
I found a gist by Adam Wathan about Troubleshooting Valet on Sierra that helped me with this issue:
https://mysite.dev
touch /Users/myusername/.valet/Log/access.log
valet restart
https://mysite.dev
. Success!@skybluesofa thanks but It didn't work with me .. also valet crashed after run secure command and it won't start until I run valet unsecure then valet start again
@ahmedash95 did you have Nginx already installed before installing Valet?
Try valet stop && brew uninstall --forge nginx
, then re-run valet install
to make sure nginx is installed with the correct flags.
@adamwathan It works .. thanks
When use valet secure,nginx needs ngx_http_v2_module
.Try nginx -t
you will get the info.
In mac,valet stop && brew uninstall --forge nginx
and brew install nginx --with-http2
now it works. the option --with-http2
activate the ngx_http_v2_module
.
PS: Valet source
Nginx.php
function install() { $this->brew->ensureInstalled('nginx', ['--with-http2']); //see this line $this->installConfiguration(); $this->installServer(); $this->installNginxDirectory(); }
Brew.php
function ensureInstalled($formula, $options = [], $taps = []) { if (! $this->installed($formula)) { $this->installOrFail($formula, $options, $taps); } }
function installed($formula) { return in_array($formula, explode(PHP_EOL, $this->cli->runAsUser('brew list | grep '.$formula))); }
So,if you installed the nginx without http2 before valet,valet secure will not work;
still not working
@hassanazimi can you show us your version, what error message you get, etc.?
@joshmanders Unfortunately there isn't any error. Everything runs well but when I wanna secure a domain like valet secure domain
everything stops working. All webpages "cannot resolve the address". I have to the remove rm -rf ~/.valet
and then valet install
then valet park
and everything works again. Summary: I can't secure a domain.
Try going into the project directory and running valet secure
without the domain and see if that works.
@joshmanders Still the same.
Had the same problem and it turned out I needed to update to the latest version of Laravel Valet. I was using 2.0.3 and now updated to 2.0.4 which solved my problem.
Hope this helps!
@blyleven well i'm using 2.0.4
@blyleven this worked for me. Thnx!
@adamwathan It works .. thanks
Still valet secure
stops everything from working and I can't figure out why. I'm sure it adds a certificate to ~/.valet
directory but everything stops from working.
I have to remove ~/.valet
directory and install valet again. this issue is about valet secure
not the valet itself.
I confirm, hassanazimi: I get the same issue - even with the above solutions
Can't replicate this, working as expected here.
Can you guys provide any more info about what isn't working? Is PHP running? Is nginx running? Is dnsmasq running? What do the log files say in PHP and nginx?
@adamwathan Like I said when I install valet it works, which means php Nginx work as well but when I want to add or secure a domain, I can't access to the laravel dev domains whatsoever, even the ones I didn't want to be secured. Php and nginx do work though. The only thing I have to do is to remove ~/.valet directory and install valet again. Can't secure any domains locally.
Are PHP and nginx running after you run valet secure
though? And what do the log files for nginx and PHP say after running that command?
Does ps aux | grep php
list several php-fpm
instances as running, like below?
Depending on if you are running 7.0 or 7.1, you'll find the FPM log in one of these locations:
/usr/local/opt/php70/var/log/php-fpm.log
/usr/local/opt/php71/var/log/php-fpm.log
...and the nginx log will be here:
~/.valet/Log/nginx-error.log
After running valet secure, what happens when you run:
sudo nginx -t
Does nginx -V
list that it was compiled --with-http_v2_module
or does that not show up?
php is running and sudo nginx -t provides nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful so strange, for: /usr/local/opt/php70/var/log/php-fpm.log /usr/local/opt/php71/var/log/php-fpm.log there is not directory for php70 and php71 gives an empty log - normal ?!? ~/.valet/Log/nginx-error.log is empty too => ?!?
@adamwathan
/usr/local/opt/php71/var/log/php-fpm.log
~/.valet/Log/nginx-error.log
ps aux | grep php
returns as follows: (no issues there)sudo nginx -t
this is what it returns: nginx: [emerg] BIO_new_file("/Users/hasan_azimi0/.valet/Certificates/persianwoo.dev.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/Users/hasan_azimi0/.valet/Certificates/persianwoo.dev.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed
Any clue Adam? I guess is permission problem but wondering how to fix.
Sounds like a certificate file didn't get generated or somehow got deleted.
Try running the following which will force Valet to regenerate all certs:
valet domain blah
valet domain dev
Thanks Adam but still no luck.
Try deleting the contents of ~/.valet/Certificates and ~/.valet/Nginx and then restarting valet.
When I try delete the content of both folders the site runs again but its not secure.
Ok so now what happens if you try to secure it again from scratch, now that things are working...?
Ok so now what happens if you try to secure it again from scratch, now that things are working...?
I can see the it generates certificates in Certificates
directory and one file in Nginx
directory and when i open the browser This site can’t be reached
and when i delete the files and valet restart
it comes back again.
So when nginx is complaining about the file that doesn't exist, does it exist? Is there a difference in the file name nginx is looking for vs. the one you actually see in the certificates folder?
It's the same, have a look:
I think it tries to read but somehow can't.
Can you screenshot running ls -la
inside of the Nginx folder?
Sure:
So actually the .crt file doesn't exist in the certificates directory which must be causing the issue. Probably something is failing during the secure stuff when trying to create the certificate.
The best I can recommend to help debug is trying to run all the steps you see in the code here manually in your terminal, and seeing if you get any errors:
https://github.com/laravel/valet/blob/master/cli/Valet/Site.php#L200-L267
https://github.com/laravel/valet/blob/master/cli/Valet/Site.php#L239
just change /C=/ST=/O=/localityName=/commonName=*.%s/organizationalUnitName=/emailAddress=/
to
/commonName=*.%s/
solved the problem
@uicosp it DID actually fix it.
Thanks
I have tried everything including delete .~/valet folder and reinstall everything, but I cannot start the website. I used to start it successfully. But after I updated homebrew, I can't open the website anymore. Any help?
probably getting php errors, you'll have to brew list
and see if you still have php71
packages installed. If so uninstall them and reinstall php@7.1
as they renamed the formula
I tried @mitoop solution to remove nginx and re-install with the --with-http2 flag. That didn't work as it gave me an unknown flag warning during the install (in the console logs) and continued to install nginx which failed to fix the bug.
I then checked the available flags using brew options nginx
to see there was no —with-http2 flag. So I did a brew uninstall nginx
and then did a brew install nginx-full --with-http2
(this had the necessary flag and you can check using brew options nginx-full
). Once installed, I did a valet install
, cd’ed into the project folder and did a valet secure
and valet open
. The bug was fixed and my project opened properly with https.
@SaifurRahmanMohsin thats great to know. thanks for taking the time to update this.
What's the difference with nginx
vs. nginx-full
anyway?
not working, tried everything
not working, tried everything
Please open a new issue, and include the output from valet diagnose
The only command that worked for me was sudo nginx -s stop && sudo nginx
Hello,
When I execute the command
valet secure
, a message says that the site has been secured with a fresh TLS certificate (as it should).If I try to access (http and https) the website, it gives me a browser 404 (so Valet does not seem to run). If I unsecure the site however, it works fine.
What could be the problem? I tried to completely remove Valet (including
~/.valet
). Still no luck :/