craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

nitro project create, nitro craft setup - Hostname Throws 404 Page Error #367

Closed jayhlee closed 2 years ago

jayhlee commented 3 years ago

Description

I can successfully create a new project and set up Craft. However, when I go to my newly created site (mysite.nitro), I get a 404 error.

Steps to reproduce

  1. nitro create myproject
  2. nitro craft setup
  3. Loading myproject.nitro in browser throws 404 error

Additional info

Nitro CLI:   2.0.8
Nitro gRPC:      2.0.7
Docker API:      1.41 (1.12 min)
Docker CLI:      1.41
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., 2.0.0-beta.1)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 10
  Running: 10
  Paused: 0
  Stopped: 0
 Images: 25
 Server Version: 20.10.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.25-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 11.68GiB
 Name: docker-desktop
 ID: P6NS:X2YX:UAZX:XTM6:TUL6:J2ZW:UZHK:BI4T:SQKO:UU52:2Q6U:RPW2
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
jayhlee commented 3 years ago

I think I figured out what the issue is. During the process of nitro create myproject, if you set the web root for the site to be public rather than the default web, a 404 error is thrown.

jasonmccallister commented 3 years ago

@jayhlee it should generate the directory for you but it might take a while to sync the files if you have a lot of assets in the site. Can you run nitro ssh and cat /etc/nginx/conf.d/default.conf and provide the output of the site that is 404'ing?

jayhlee commented 3 years ago

The issue seems to be that when you create a new project using nitro create <myproject> and you choose the web root to be something other than web, a 404 error is thrown because the web root directory that's created is still web. The fix is easy, which is to just change web to the name of the web root you specified during the nitro create process.

Not sure if others may have gotten stuck on this. But it'd be nice if the name of the web root that's specified during the nitro create process would generate the web root file to reflect that name (rather than create a web web root directory indiscriminately).

jasonmccallister commented 3 years ago

@jayhlee what is the web root defined in your nitro.yaml site config?

jayhlee commented 3 years ago

The web root defined in nitro.yaml is set to what it was defined as when nitro create was run. So if it was set to public, it'll be defined as public. The hiccup, however, is that if you define the web root as public (or something else other than web) during the nitro create process, the files and folders that are built will create a folder named web—regardless of what you actually defined it to be during the nitro create process. And this is what causes the issue.

As I mentioned, the fix is simple. Namely, to just rename the generated web folder to public (or whatever it was named during the nitro create process). But it'd be nice to have the generated web root folder be named to what it was defined as during the nitro create process. I assumed this would be the case, which was where I went astray.

peteralewis commented 3 years ago

Just adding to this that I've hit the same issue. During setup I defined the web root as "public" and it created a folder called "web" instead, but the nitro.yaml file correctly had referenced it as "public". Yes it's an easy fix to just rename the folder, but evidently the nitro create script is asking the question and not using that answer when creating the folder.

jasonmccallister commented 2 years ago

Hi, we are closing this issue as we have decided to retire Nitro, so no additional work will occur on this project. You can read the official blog post here https://craftcms.com/blog/retiring-craft-nitro. We appreciate everyones feedback and involvement and we look forward to refocusing our efforts on Cloud!

If you're looking for a new local development environment, we recommend DDEV and have a knowledge base article to help you with the transition: https://craftcms.com/knowledge-base/migrating-from-craft-nitro-to-ddev.