Q:

Laravel Forge - access app by naked IP instead of domain name

I have a laravel app on production (using Laravel Forge and a Digital Ocean droplet).
I'm able to access the app via www.domain.com, but if I try with the server's IP I get a 404 (nginx).
How can I manage to access the app with the IP address?
Thanks a lot for your help
EDIT:
Here is my Nginx config on Laravel Forge:
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name domain.com;
    root /home/forge/domain.com/public;
    ...
}

A:

This occurs because nginx searches for a configuration block containing default_server when no matching domain can be found. You can remove the default_server tag for the default(/etc/nginx/enabled-sites/default) and move it the config for the site you want to display by default:
server {
    listen      80 default_server;
    server_name example.net www.example.net;
    ...
}

your server block with updated default_server:
server {
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2;
    server_name domain.com;
    root /home/forge/domain.com/public;
    ...
}

Be sure to edit the default config to remove the default_server tag before restarting nginx, it is not allowed to have two config blocks with default_server. The config can be verified using nginx -t
more information can be found at the nginx documentation

