How to setup a Adonis js app in CyberPanel

I’m having trouble loading the application. When accessing the subdomain an infinite load is shown and nothing happens.

I tried to use several available tutorials and still without success

SSL work Migration Work

See below

I’m use AdonisJs

context / {

type appserver

location /home/dominio.com/aplicativo

binPath /usr/bin/node

appType node

startupFile server.js

maxConns 100

rewrite {

}

addDefaultCharset off

}

ThankYou

It sounds like you’re experiencing an issue with loading your AdonisJS application on a subdomain, and you’re facing an infinite loading issue. Here are some steps to troubleshoot and potentially resolve the problem:

1. Check Server Logs

First, check the logs for any errors that might provide more insight into why the application isn’t loading:

  • AdonisJS Logs: Look in the logs directory of your AdonisJS application (usually found in app/Logs).
  • Web Server Logs: Check the logs for the web server you’re using (e.g., Nginx or Apache) for any related errors.

2. Verify Configuration

Make sure your server configuration is set up correctly. Based on the context you provided, ensure that:

  • Document Root: Ensure that the document root for your subdomain points to the correct directory for your AdonisJS application.
  • Location Block: If you’re using Nginx, ensure that your configuration includes the correct location block. For example:
server {
    server_name subdomain.dominio.com;

    location / {
        proxy_pass http://localhost:3333;  # Change port if your Adonis app uses a different port
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

3. Check AdonisJS Application

Make sure your AdonisJS application is running properly:

  • Start the Server: Ensure the server is running. You can use:
node server.js
  • Check for Errors: If the server fails to start, check for any error messages in the terminal.

4. Node.js Version

Ensure you are using a compatible version of Node.js with AdonisJS. You can check your Node.js version with:

node -v

5. Firewall and Security Groups

Ensure that your server’s firewall settings or security groups (if using a cloud provider like DigitalOcean) allow traffic on the port your application is running on (usually port 3333 for AdonisJS).

6. Proxy Settings

If you’re using a reverse proxy (like Nginx or Apache) in front of your AdonisJS application, ensure that the proxy settings are configured correctly to handle WebSocket connections if you’re using them.

7. SSL Configuration

If SSL is enabled, ensure that the SSL certificates are correctly set up and that the configuration allows traffic over HTTPS.

8. Check Network and DNS

Verify that the DNS settings for your subdomain are correctly pointing to your server’s IP address. You can use tools like nslookup or dig to check DNS resolution.

9. Test Direct Access

Try accessing your AdonisJS application directly via the port it’s running on (e.g., http://your-server-ip:3333) to see if it loads properly. This will help determine if the issue is with the application itself or with the web server configuration.

10. Restart Services

After making changes, restart your web server and the AdonisJS application to ensure all configurations are applied.

Example Nginx Configuration

Here’s a complete example of an Nginx configuration for an AdonisJS app:

server {
    listen 80;
    server_name subdomain.dominio.com;

    location / {
        proxy_pass http://localhost:3333;  # Change the port if needed
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    # Optional: Redirect HTTP to HTTPS
    listen 443 ssl;
    ssl_certificate /path/to/your/cert.pem;
    ssl_certificate_key /path/to/your/key.pem;
}

Conclusion

If you’ve tried all of these steps and are still experiencing issues, please provide any error messages from the logs or configuration files, and I can help further diagnose the problem!