Running production gets 404 #1649
-
|
I have a working local debug Loco app running normally. but when I run it with # Application logging configuration
logger:
# Enable or disable logging.
enable: true
# Enable pretty backtrace (sets RUST_BACKTRACE=1)
pretty_backtrace: true
# Log level, options: trace, debug, info, warn or error.
level: debug
# Define the logging format. options: compact, pretty or json
format: compact
# By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries
# Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters.
# override_filter: trace
server:
# Port on which the server will listen. the server binding is 0.0.0.0:{PORT}
port: 3001
# Binding for the server (which interface to bind to)
binding: localhost
# The UI hostname or IP address that mailers will point to.
host: http://localhost
middlewares:
# Database Configuration
database:
# Database connection URI
uri: {{ get_env(name="DATABASE_URL", default="sqlite://xlp_production.sqlite?mode=rwc") }}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.
connect_timeout: {{ get_env(name="DB_CONNECT_TIMEOUT", default="500") }}
# Set the idle duration before closing a connection.
idle_timeout: {{ get_env(name="DB_IDLE_TIMEOUT", default="500") }}
# Minimum number of connections for a pool.
min_connections: {{ get_env(name="DB_MIN_CONNECTIONS", default="1") }}
# Maximum number of connections for a pool.
max_connections: {{ get_env(name="DB_MAX_CONNECTIONS", default="1") }}
# Run migration up when application loaded
auto_migrate: true
# Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_truncate: false
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_recreate: false
# Authentication Configuration
auth:
# JWT authentication
jwt:
# Secret key for token generation and verification
secret: secret-token
# Token expiration time in seconds
expiration: 604800 # 7 days
cors:
enable: true
allow_headers:
- content-type
- accept
- X-API-KEY
allow_origins:
- http://localhost:5173/
- http://localhost:5150
It's a simple app with one controller and two nested paths. Running On production: ❌ SeaORM CLI was not found
To fix, run:
$ cargo install sea-orm-cli
✅ DB connection: success
⚠️ queue not configured?
✅ Dependencies
✅ Loco version: latestI installed the SeaORM CLI, and it's the same error. I can see the log in the server when accessing the root endpoint. It's behind an 2025-10-05T12:16:14.129155Z DEBUG http-request: tower_http::trace::on_request: started processing request http.method=GET http.uri=/ http.version=HTTP/1.1 http.user_agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 environment=production request_id=d50a36cb-eeaf-40e5-ba29-a163927b6df3
2025-10-05T12:16:14.129245Z DEBUG http-request: tower_http::trace::on_response: finished processing request latency=0 ms status=404 http.method=GET http.uri=/ http.version=HTTP/1.1 http.user_agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 environment=production request_id=d50a36cb-eeaf-40e5-ba29-a163927b6df3
2025-10-05T12:16:14.318271Z DEBUG http-request: tower_http::trace::on_request: started processing request http.method=GET http.uri=/ http.version=HTTP/1.1 http.user_agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 environment=production request_id=0e5c92d5-8f4a-4ac1-9f19-020b1cf22931
2025-10-05T12:16:14.318359Z DEBUG http-request: tower_http::trace::on_response: finished processing request latency=0 ms status=404 http.method=GET http.uri=/ http.version=HTTP/1.1 http.user_agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 environment=production request_id=0e5c92d5-8f4a-4ac1-9f19-020b1cf22931nginx: server {
# Apps directory
root /home/git/apps/api-app/;
server_name api.app.tld;
add_header Access-Control-Allow-Origin *;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:3001;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
# Allow the use of websockets
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;
}
# listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/api.app.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.app.tld/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}This could be an nginx config issue. I'll try moving it to another linux box that has several apps running behind nginx successfully. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I deployed my app to another VM, it works now. Not sure why. This is my server {
server_name api.app.tld; # managed by Certbot
location / {
proxy_pass http://127.0.0.1:3014;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/api.app.tld/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/api.app.tld/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = api.app.tld) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name api.app.tld;
return 404; # managed by Certbot
} |
Beta Was this translation helpful? Give feedback.
I deployed my app to another VM, it works now. Not sure why. This is my
nginxconfig for reference: