I created the example create-next-app@14 nextjs app on my rhel server (which has node on it) and I let it run on port 3000 (using either npm run dev or start after building). I also configured a reverse proxy on apache to reverse proxy from 10.xx.xx.09/testwebsite/ to http://localhost:3000/
When I visit 10.xx.xx.09/testwebsite/ on my web browser, I can see the html, but none of the images or css styling. It’s almost like the static files aren’t being served. I tried to modify my next.config.mjs to set a basepath so that nextjs would generate the correct paths for my static assets, but then the web address gives me 404 not found.
Here is my virtual host/reverse proxy
<VirtualHost *:80>
ServerName 10.xx.xx.09
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Proxy settings for requests to /test/
ProxyPreserveHost On
ProxyErrorOverride Off
ProxyPass /testwebsite/ http://localhost:3000/
ProxyPassReverse /testwebsite/ http://localhost:3000/
</VirtualHost>
2
Answers
I was able to fix my issue by adding an asset prefix to my next.config.mjs
My apache proxy looks like
My nextjs app is running on localhost:3000 on the server/
Example configuration maybe helpful