stueynet

stueynet

Member Since 5 Years Ago

Experience Points 20,340
Experience Level 5

4,660 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 253
Lessons
Completed
Best Reply Awards 3
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

16 Apr
3 months ago

stueynet started a new conversation Laracon Cancellations

Where does one make Laracon tickets available. Taylor often announces they have cancellations. What is the process for cancelling if you have tickets?

05 Jan
6 months ago

stueynet left a reply on Switching From Composer Installation To Local

@D9705996 - Yeah. That also happens when you composer update. Actually just solved it. Had to remove it from composer.json, then run composer clear-cache then install it all again.

stueynet started a new conversation Switching From Composer Installation To Local

So strange thing happening. I had originally installed Nova using the copy the whole zip file method. At version 1.1.6 I decided to try the private Satis repository. I then switched back, yet I cannot seem to get it to reference the local version again. The files are there in /nova and the composer.json file has:

"repositories": [
        {
            "type": "path",
            "url": "./nova"
        }
    ],

Ran composer install and all the other stuff and yet it still references the nova from /vendor/laravel/nova.

Any thoughts on this?

31 Dec
6 months ago

stueynet started a new conversation VSCode Autocomplete For Route Names, Configs Etc...

I recently made the switch to VSCode from phpstorm. Overall I am pleased but I am really missing the amazing auto completion for laravel helpers. For example:

view('... route('... config('... @lang('...

For all of these it would give you an autosuggest for available files, config definitions etc...

I have tried all the Laravel plugins for VSCode. Am I missing something or is this just not available?

03 Nov
8 months ago

stueynet started a new conversation Homestead Curl Error 77 When Using Guzzle

Just trying to make a simple external API call using the latest guzzle in laravel.

Environment: Homestead 6.3, PHP 7.2

Code:

$client = new Client(); //GuzzleHttp\Client
return $result = $client->get($url);

Error:

cURL error 77: error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.cr CApath: /etc/ssl/certs (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
21 Oct
8 months ago

stueynet left a reply on LARAVEL NOVA: Display Total Number Of Rows

Been all over the Nova issues board and there seems to be no elegant way to do this. Perhaps a new Nova package is needed for this. It would seem with such a robust filtering system built in, showing the number of results produced by said filter would make perfect sense.

12 Sep
10 months ago

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

So that was it. /register fixed it. Crazy. Thanks @Tray2

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

Yup correct file and everything. This is for sure going to be one of insanely stupid things I am sure of it.

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

Yeah it’s insane. I can tell you it’s the same issue with other tests. And definitely have the routes in place. I’m going to try your test above when I get back to the office. Thanks for the help so far really appreciated!

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

And yeah its a TestResponse:

[email protected]:~/Code/wpcore-app2$ vendor/bin/phpunit
PHPUnit 7.3.2 by Sebastian Bergmann and contributors.

F"Illuminate\Foundation\Testing\TestResponse"
[email protected]:~/Code/wpcore-app2$

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

One of the million things I tried. I have dumped all the env, every database config etc... nothing seems to work. Here is a screencast proving the environment

https://d.pr/v/6YwEAH

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

Laravel 5.6. The whole file is above but here is a screencast attempting to dump the things:

https://d.pr/v/kNczwW

$response->dump();

It would appear that the test response is an instance of Query Builder.

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

This is the entire test file:

<?php

namespace Tests\Feature;

use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UserTest extends TestCase
{
    /**
     * @test
     */
    public function a_guest_should_be_able_to_register()
    {
        $this->post('register', [
            'username' => 'TestUser',
            'email' => '[email protected]',
            'password' => 'Password123',
            'password_confirmation' => 'Password123',
            'terms' => '1',
        ]);

        $this->assertDatabaseHas('users', [
            'email' => '[email protected]',
            'username' => 'TestUser',
        ]);
    }

    /**
     * @test
     */
    public function a_guest_should_be_able_to_see_the_register_page()
    {
        $response = $this->get('/register');

        $response->assertStatus(200);
    }

    /**
     * @test
     */
    public function a_guest_should_be_able_to_see_the_login_page()
    {
        $response = $this->get('/login');

        $response->assertStatus(200);
    }

    /**
     * @test
     */
    public function a_loggedin_user_should_not_be_able_to_see_the_login_page()
    {
        $user = factory(User::class)->create();
        $this->actingAs($user);

        $response = $this->get('/login');

        $response->assertRedirect('/dashboard');
    }

    /**
     * @test
     */
    public function a_loggedin_user_should_not_be_able_to_see_the_register_page()
    {
        $user = factory(User::class)->create();
        $this->actingAs($user);

        $response = $this->get('/register');

        $response->assertRedirect('/dashboard');
    }



    /**
     * @test
     */
    public function a_guest_should_be_able_to_login_with_valid_credentials()
    {
        $user = factory(User::class)->create();

        $response = $this->post('/login', [
            'email' => $user->email,
            'password' => 'secret'
        ]);
        $response->assertStatus(302);
        $this->assertAuthenticatedAs($user);
    }

    /**
     * @test
     */
    public function a_loggedin_user_can_see_the_dashboard()
    {
        $user = factory(User::class)->create();
        $this->actingAs($user);

        $response = $this->get('/dashboard');

        $response->assertOk();
    }
}

and here is my Testcase file

<?php

namespace Tests;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, RefreshDatabase;
}

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

Weird it seems to be dumping the whoops page;

              </tr>\n
                          <tr>\n
                <td>MIX_PUSHER_APP_KEY</td>\n
                <td><pre class=sf-dump id=sf-dump-2125244751 data-indent-pad="  ">""\n
</pre><script>Sfdump("sf-dump-2125244751")</script>\n
</td>\n
              </tr>\n
                          <tr>\n
                <td>MIX_PUSHER_APP_CLUSTER</td>\n
                <td><pre class=sf-dump id=sf-dump-927012176 data-indent-pad="  ">"<span class=sf-dump-str title="3 characters">mt1</span>"\n
</pre><script>Sfdump("sf-dump-927012176")</script>\n
</td>\n
              </tr>\n

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

Here is is:

        \DB::enableQueryLog();
        $this->post('register', [
            'username' => 'TestUser',
            'email' => '[email protected]',
            'password' => 'Password123',
            'password_confirmation' => 'Password123',
            'terms' => '1',
        ]);

        dd(\DB::getQueryLog());

Output:

[]
11 Sep
10 months ago

stueynet left a reply on In Memory Database Leads To The Table Is Empty.

Same problem here. All the setup is correct. Tried it with multiple database types including :memory: and a full mysql database. Been troubleshooting this for two weeks as I continue to build with no tests.

30 Aug
10 months ago

stueynet started a new conversation In Memory Database Leads To The Table Is Empty.

Decided to try out the in memory DB for testing on a new project. Using Homestead and the latest Laravel. Can't seem to get things working no matter what I try. Been through all of the threads on all the sites and nothing seems to be working. Here is my stuff:


//config/database.php


    'connections' => [
        'testing' => [
            'driver' => 'sqlite',
            'database' => ':memory:',
            'prefix' => '',
        ],


// phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>
        
        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="DB_CONNECTION" value="testing"/>
        <env name="BCRYPT_ROUNDS" value="4"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="MAIL_DRIVER" value="array"/>
    </php>
</phpunit>

I have been clearing my config cache constantly.

TestCase.php uses the RefreshDatabase trait and I have even done this in a number of places down the testing chain to confirm its the right database being used during the tests:

        $connection = config('database.default');

        $driver = config("database.connections.{$connection}.database");
        dd($driver);

Anyone have any other tricks they know of to get this working?

28 Mar
1 year ago

stueynet left a reply on Passing A Variable Into Blade Directive Doesn't Pass Variable Content, But Name Of Variable

Here I am resurrecting this thread. @kmsch did you ever figure this one out? I am doing a similar thing where we have a simple blade directive and want to pass it a variable just like we would do with built in directives. Nothing seems to work.

@custom($variable)simply gives you $variable. Here is the directive:

Blade::directive('custom', function ($input) {
    return echo $input;
});
27 Dec
1 year ago

stueynet started a new conversation Urls With A Php Extension Cause An Error Instead Of A 404

When you visit a missing url with a php extension it creates an nginx error and shows No input file specified.. The errors logs show:

FastCGI sent in stderr: "Unable to open primary script: /home/forge/example.com/current/public/1.php (No such file or directory)" while reading response header from upstream, client: 99.243.66.152, server: www.example.com, request: "GET /1.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "www.example.com"

This occurs on the forge website itself as well so its not a configuration issue on my end. Just wondering why this is the case. I am finding that bots that are trolling my site for login pages such as wp-login.php are creating tons of errors in the logs.

Example: https://forge.laravel.com/idontexist.php

21 Nov
1 year ago

stueynet left a reply on Rename Redis Alias To What?

Yeah makes sense.

stueynet left a reply on Rename Redis Alias To What?

I am not using it directly. I am using it as the cache and queue driver so there is nowhere in our code that we directly reference ‘Redis’

stueynet left a reply on Rename Redis Alias To What?

@tykus ok so if we are not calling ourselves form somewhere then it doesn't matter.

stueynet started a new conversation Rename Redis Alias To What?

Following this page: https://laravel.com/docs/5.5/redis#phpredis

PhpRedis
If you have the PhpRedis PHP extension installed via PECL, you will need to rename the  Redis alias in your config/app.php configuration file.

That warning doesn't say what to rename it to?

18 Aug
1 year ago

stueynet started a new conversation Cashier Reminders For Upcoming Payments

Wonder if anyone has set up reminders for upcoming subscription payments using cashier? I am looking at implementing this as a courtesy to customer. I guess the problem I have is that the cashier subscriptions table only has created_at. I could run a cron job that takes all subscriptions where ends_at is null and now is x periods from created_atbut that doesn't really help me for subsequent periods. I figured someone must have dealt with this issue?

14 Aug
1 year ago

stueynet started a new conversation Is It Necessary To Queue Something That Runs From A Cron-based Console Comand

For example, you have a console command that sends a whack of emails to some subset of users every night. Is it necessary to queue the email jobs? Is there a benefit to still pushing them onto the queue? My assumption is that their might be because your queues may have multiple workers? Not sure. Interested in people's thoughts.

16 Jul
2 years ago

stueynet started a new conversation Bug Or Feature? Artisan Command Fires With Colon Only

I just happened across this today. If you call an artisan command without the second half, if the namespace only has one available that command will still fire. For example:

php artisan event:generate and php artisan event: both execute the same. I came across this because I was looking to see what commands were in a namespace and typed in just the first part but added the colon by mistake.

10 Jul
2 years ago

stueynet started a new conversation Forge Queue Error Logs?

I have 4 sites running on forge and it seems one of them is not able to get its queue started. I am trying to find where forge stores the queue error logs. Here is a screenshot of the failed worker but not sure where the log is.

http://d.pr/i/LP0Dsu

stueynet left a reply on Does Redis Caching Require Anything On Than Predis/predis?

Thanks @martinbean thats what I was thinking. So that means that homestead and forge automatically get that all up and running automagically, since it literally just worked after

composer require predis/predis

and then changing .env:

CACHE_DRIVER=redis

stueynet started a new conversation Does Redis Caching Require Anything On Than Predis/predis?

I am wondering if using redis for caching will just work on any server if predis/predis is installed. Seems to work fine in Homestead and on Forge but our production server is not on Forge so I want to make sure Forge doesn't do anything in the background to get it ready for redis caching. Thanks!

04 Jul
2 years ago

stueynet left a reply on Dispatching Jobs From A Model

Thanks @spekkionu much appreciated. I am looking at refactoring to events as well so that may just solve it all. I actually originally had events and found I kept want to more easily just dispatch jobs so I converted all queued things to jobs and just fire them from service classes when necessary.

stueynet started a new conversation Dispatching Jobs From A Model

Anyone have an issue with me doing use DispatchesJobs in a model as opposed to a Controller or service? I found in a certain case I wanted a job run on the User model and it was easiest to just do $user->jobMethod() and then in a Trait on the User model use the dispatcher and fire the job. One issue was that if more than one Trait use DispatchesJobs you would have a collision. So I just added use DispatchesJobs right on User.php. Interested in hearing thoughts for or against.

16 Jun
2 years ago

stueynet started a new conversation Forge Letsencrypt ERROR: Challenge Is Invalid! (returned: Invalid)

So I had an issue back in March when Forge letsencrypt renewals failed. I ended up having to delete and rebuild the site on forge to get things back up and running. Unfortunately it looks like the renewals have not been working again so I am trying to manually issue a new one so I can remove the old one. Problem is when I try and so that I get this error. There are similar threads but they say to make sure the DNS records are set up correctly which they are. I am wondering is there another fix for this? Can't get any repsonse from the forge team on this so hoping someone here can give a fellow a hand.

Creating well known challenge directory...
Installing LetsEncrypt client...
Cloning into 'letsencrypt1497641525'...
Configuring client...
Restarting Nginx...
Generating Certificate...
# INFO: Using main config file /root/letsencrypt1497641525/config
+ Generating account key...
+ Registering account key with ACME server...
+ Done!
# INFO: Using main config file /root/letsencrypt1497641525/config
Processing domain.ca with alternative names: www.domain.ca
 + Signing domains...
 + Creating new directory /root/letsencrypt1497641525/certs/domain.ca ...
 + Generating private key...
 + Generating signing request...
 + Requesting challenge for domain.ca...
 + Requesting challenge for www.domain.ca...
 + Responding to challenge for domain.ca...
 + Challenge is valid!
 + Responding to challenge for www.domain.ca...
ERROR: Challenge is invalid! (returned: invalid) (result: {
  "type": "http-01",
  "status": "invalid",
  "error": {
    "type": "urn:acme:error:unauthorized",
    "detail": "Invalid response from http://www.domain.ca/.well-known/acme-challenge/2UFlHz0BH7wZCld9zfv09uwfpKYcRtK3hJboZ7k-nsE: \"\u003c!--\n                              |\n  __ `__ \\     _` |   __ \\    |    _ \\\n  |   |   |   (   |   |   |   |    __/\n _|  _|  _|  \"",
    "status": 403
  },
  "uri": "https://acme-v01.api.letsencrypt.org/acme/challenge/YUD_tqLk7NVLX6s84FwaeWKMUbc5TXQAc6V3hBVJa8U/1353789835",
  "token": "2UFlHz0BH7wZCld9zfv09uwfpKYcRtK3hJboZ7k-nsE",
  "keyAuthorization": "2UFlHz0BH7wZCld9zfv09uwfpKYcRtK3hJboZ7k-nsE.-383PFv7SmF22NkwU1M_nI03hKiykde0sg1hDPVqrMI",
  "validationRecord": [
    {
      "url": "https://www.domain.ca",
      "hostname": "www.domain.ca",
      "port": "443",
      "addressesResolved": [
        "XXX.203.4.45"
      ],
      "addressUsed": "XXX.203.4.45",
      "addressesTried": []
    },
    {
      "url": "http://www.domain.ca/.well-known/acme-challenge/2UFlHz0BH7wZCld9zfv09uwfpKYcRtK3hJboZ7k-nsE",
      "hostname": "www.domain.ca",
      "port": "80",
      "addressesResolved": [
        "XXX.203.4.45"
      ],
      "addressUsed": "XXX.203.4.45",
      "addressesTried": []
    }
  ]
})

stueynet left a reply on Problem Installing SSL Certificate

@samdevries Any other reason this may happen? My DNS is all set up properly and always has been. I am trying to re-issue the certificate because for some reason forge decided not to automatically renew it ever week as it is supposed to.

15 Jun
2 years ago

stueynet left a reply on PDO Error

Guys sorry to resurrect this thread but I am wondering what the implications are of changing that setting. Also is this masking a performance problem in the code perhaps? I am noticing it only happens as part of the running of a Queued job and always happens during a simple select statement.

eg:

Illuminate\Database\QueryException·PDO::prepare(): send of 57 bytes failed with errno=32 Broken pipe (SQL: select * from `users` where `users`.`id` = 4582 limit 1)

By upping the timeout in mysql will this have any other unintended consequences?

20 Apr
2 years ago

stueynet left a reply on Getting Statistics On Subscriptions With Cashier

@Jaytee I was thinking about setting up a Subscription model actually but was worried it would clash with the Cashier Subscription model. I'm going to go ahead and give that a whirl now.

stueynet left a reply on Getting Statistics On Subscriptions With Cashier

Thanks @Hawkleaf. Its not the charting I am looking for. Just a simple way to count Cashier subscriptions, not using the two ways I outlined above.

stueynet started a new conversation Getting Statistics On Subscriptions With Cashier

First off this can be done with raw DB queries on the subscriptions table. I can also do this by filtering a user collection as follows:

$users->filter(function ($user) {
         return $user->subscribedToPlan('family');
})->count(),

However I was hoping someone might have a more fluent method for getting information about subscriptions. At the most base level I want to see the number of subscriptions of a particular plan.

Thanks in advance!

30 Mar
2 years ago

stueynet left a reply on Autocompletion For Custom Facades In PhpStorm

Would love to hear about this @vgaldikas

24 Mar
2 years ago

stueynet left a reply on Redirect Loop For Non-www Domains To Www Domain.

Ok to anyone who is listening I have this all figured out. When you enable ssl for a domain a new file is added at /etc/nginx/forge-conf/domain.com/before/ssl_redirect.conf. The is run before your normal nginx file located at /etc/nginx/sites-available/domain.com. So in the new file you need to do the following:

Change:

server_name .domain.com;

to

server_name domain.com;

Closer to the bottom change:

server_name www.domain.com;
return 301 https://getmaple.ca$request_uri;

to

server_name domain.com;
return 301 https://www.getmaple.ca$request_uri;

And final back in your /etc/nginx/sites-available/domain.com file change server_name domain.com; to server_name www.domain.com;

23 Mar
2 years ago

stueynet started a new conversation Using Forge-conf To Add Additional Nginx Directives

I am finding the need to do some other things in nginx configuration files, and I see

/etc/nginx/forge-conf/test.com$ ls
after  before  server

These are included in the sites-available/test.com config files.

Is this the recommended place to make nginx.conf file changes like adding new server blocks etc? It seems like it is but I am wondering if these are reserved for forge to overwrite at certain times.

Thanks in advance!

19 Mar
2 years ago

stueynet left a reply on Catch-all Config Not Firing On Direct IP Entry

Damn. Ok so we have the exact same setup. Wonky.

stueynet left a reply on Catch-all Config Not Firing On Direct IP Entry

What does your catch-all file have in it?

stueynet left a reply on Catch-all Config Not Firing On Direct IP Entry

Yeah so I have that file as well. But for whatever reason it doesn't get triggered when you visit from the IP. I am wondering where at a higher level that catch-all is referenced? I did not see any reference to it anywhere which leads me to believe perhaps the server setup is not complete. I set up this server a year ago and since then lots of config and feature change son forge have occurred. Do you happen to know where the catch-all config is called?

stueynet left a reply on SSL Stopped Working

@_chris the issues was tweeted here: https://twitter.com/laravelphp/status/843173737830780929

Unfortunately for some people depending on their setup, things got a little screwy. I had a few sites with customized nginx config files which got quite corrupted when I attempted to re-issue the cert. I ended up having to simply delete the site from forge and recreate it.

In your case it does sound like you will need to create a new site with the proper domain of your site in order to issue the ssl certificate. This is pretty clear in the forge instructions when you create a site that you should create one under the domain name and then delete the default site from the server.

As a process I would suggest you backup any uploaded / user files if applicable, then create a new site under the domain name. Re install your application and copy back any files from

/home/forge/default/storage

to

/home/forge/newdomain.com/storage/

Make sure sure you also copy the contents of your .env file from /home/forge/default. You can do this via the forge UI or directly on your server.

Once thats set up you should be able to issue the certificate for the new site.

stueynet left a reply on Catch-all Config Not Firing On Direct IP Entry

Laravel forge. I don't think Valet or Homestead are related as they are for local development only.

$: /etc/nginx/sites-available/catch-all

server {
    return 404;
}

This does not seem to be acting as a catchall.

stueynet started a new conversation Catch-all Config Not Firing On Direct IP Entry

Perhaps I am wrong but my understanding is that if you browse directly by IP address and you don't have a default site setup, the catch-all nginx config file located at /etc/nginx/sites-available/catch-all should take effect. That file has a 404 return in it. Yes in my case when I type the IP in directly it simply redirects to the first available site on my server based on hostname.

Anyone else have this issue? How does the catch-all nginx config get referenced? I cannot find that in my main nginx.conf file.

stueynet left a reply on Nginx 404 Error On New App

Although that being said, I am finding when I delete the default site it actually redirects me to the first available site on the server. Hmmm.

stueynet left a reply on Nginx 404 Error On New App

If you tried to reach the site by the IP address, that would normally have been handled by the default site. Since you deleted it, it is handled by the catch-all nginx config which returns a 404.

stueynet left a reply on Redirect Loop For Non-www Domains To Www Domain.

I figured I would bump this now as it seems forge has changed its nginx setup. Also given everyone uses ssl now since its basically automatic, it would be great to see the ssl version of this fix.

When you set up a new site in forge, there only appears to be a single nginx config file at /etc/nginx/sites-available/sitename.com. Once you ssl that it looks like:

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/sitename.com/before/*;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name sitename.com;
    root /home/forge/sitename.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/sitename.com/182548/server.crt;
    ssl_certificate_key /etc/nginx/ssl/sitename.com/182548/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'SHA-...';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/sitename.com/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/sitename.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/sitename.com/after/*;

What would be the new steps to adjust the above config to force www?

18 Mar
2 years ago

stueynet left a reply on So Forge Just Completely *hit The Bed

So got everything back up and running. After checking through all the nginx logs, it seems the auto update of letsencrypt caused my nginx conf file for that particular site to get munged up and never actually saved the new certs. So the nginx was pointing to unavailable files. So I had to try and revert the config back to a non-ssl version and that created all sorts of issues. Long story short I deleted the site and created a new one.

Moral: Automated ssl renewal is bad