Hi. This is a follow up to the issue I posted earlier with the Github app/https://github.com/berat/waitlist-landing-page. The app is a node app that I wanted to display via Apache/ubuntu. I'm posting this here as a dat apoint to anyone who might search for node/pm2/apache/reverse proxy! There are other ways to handle this, but this is what I managed to put together, and it seems to work for now. If others can update the solution, or provide additional insight/information to make it better, feel free to expand the solution. As an example, the "regaex" could use an explanation as to what's going on with the couple of lines of the copnmfig file. Steps to run: download app from github i choose to use /var/www/html/berat_tmp /var/www/html/berat copy into berat_tmp setup the ubuntu server update with updated apps/packages npm install pm2 -g (global) -- for the node pm2 server --- this runs locally to hande the berat/node app within berat_tmp/package.json -- setup/update the packages/dependencies in the berat_tmp dir rm package-lock.json rm -rf node_modules npm install npm run build ---->> creates the .next cp the .next to the "berat" dir run from the "berat" dir which has the .next files in the dir.. cd /var/www/html/berat rm -rf berat/* chown -R www-data:www-data berat chmod -R 777 berat cp -rf berat_tmp/.next/. berat/. a2dissite berat a2ensite berat systemctl restart apache2 rm -rf /root/.pm2 ls -al /root/.pm2 pkill -f PM2 ps -aux | grep -i "PM2" <<<< use this from html/berat dir pm2 start npm --name "waitlist-landing-page" -- start to verify the PM2 is running.. curl http://127.0.0.1:3000 ======================================================================== test berat.conf # # aug23_24 # # <VirtualHost *:80> ServerAdmin foo@xxxxxxxxx ServerName temp22qq ServerAlias tempqq ProxyRequests Off ProxyPreserveHost On ProxyVia Full DocumentRoot /var/www/html/berat #test for styles.. #does order matter??? -- the actual ip is used to test.. RewriteEngine On #try using the attached dir RewriteRule ^/?$ /berat/ [R=permanent,L] <Location "/berat"> ProxyPass http://127.0.0.1:3000 </Location> ProxyPassReverse /berat http://127.0.0.1:3000 #ttest substitute below RewriteEngine On SetOutputFilter INFLATE;proxy-html;SUBSTITUTE;DEFLATE; ProxyHTMLInterp On ProxyHTMLExtended Off AddOutputFilterByType SUBSTITUTE text/html Substitute "s|/_next/static/|\.\./\.next/static/|" Substitute "s|/_next/image\?url=\%2Fhero.jpg\&w=1920\&q=75|\.\./public/hero1|i" <Directory /var/www/html/berat> Header Set Pragma "no-cache" Header Set Expires "Thu, 1 Jan 1970 00:00:00 GMT" Header Set Cache-Control "max-age=0, no-store, no-cache, must-revalidate" Header Unset ETag FileETag None # Options -Indexes +FollowSymLinks +MultiViews #a Options -Indexes +FollowSymLinks Options -Indexes AllowOverride All #use for 2.4? Require all granted ##Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> LogLevel debug ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> On Fri, Aug 23, 2024 at 1:13 PM bruce <badouglas@xxxxxxxxx> wrote: > > (had created a thread for this a few days ago.. but it was > accidentally deleted!) > > Hi Frank/list. > > This is continuing on my issue of figuring out how to have a test > github/node app run from apache2. > > Instead of getting the site content, I seem to get -->"403 forbidden > No matching DirectoryIndex..." > > > my test ip is http://161.35.5.174/berat. > > In order to test that I can access the test url, I created a test app, > that I could access without the reverse proxy. The > test was http://161.35.5.174/berat/aa.html, and displyed the test > msg.. So, getting to the "site/url" should work. > > As I've mentioned before, the test app: > https://github.com/berat/waitlist-landing-page > It's a node app that I'm running -- http://127.0.0.1:3000 > and using "pm2" and reverse proxy with apache2 to serve the page. > > The test url is -->> http://161.35.5.174/berat (if it were to work, > as it did for a bit) > > The docroot > /var/www/html/berat > > config file > /etc/apache2/berat.conf > cat berat.conf > > > <VirtualHost *:80> > ServerAdmin foo@xxxxxxxxx > ServerName temp22 > ServerAlias temp > > DocumentRoot /var/www/html/berat > > RewriteEngine On > > ProxyPass /berat http://127.0.0.1:3000 > ProxyPassReverse /berat http://127.0.0.1:3000 > > RewriteEngine On > > SetOutputFilter INFLATE;proxy-html;SUBSTITUTE;DEFLATE; > ProxyHTMLInterp On > ProxyHTMLExtended Off > > > AddOutputFilterByType SUBSTITUTE text/html > Substitute "s|/_next/static/|\.\./\.next/static/|" > > Substitute > "s|/_next/image\?url=\%2Fhero.jpg\&w=1920\&q=75|\.\./public/hero1|i" > > > <Directory /var/www/html/berat> > > Header Set Pragma "no-cache" > Header Set Expires "Thu, 1 Jan 1970 00:00:00 GMT" > Header Set Cache-Control "max-age=0, no-store, no-cache, must-revalidate" > Header Unset ETag > FileETag None > > > Options +FollowSymLinks +MultiViews > > AllowOverride All > > #use for 2.4? > Require all granted > > > </Directory> > > LogLevel debug > ErrorLog ${APACHE_LOG_DIR}/error.log > CustomLog ${APACHE_LOG_DIR}/access.log combined > </VirtualHost> > > for the above berat.conf, I've tested the following as well: > > ProxyPass /berat http://127.0.0.1:3000/ > ProxyPassReverse /berat http://127.0.0.1:3000/ > > ProxyPass /berat/ http://127.0.0.1:3000/ > ProxyPassReverse /berat/ http://127.0.0.1:3000/ > > ProxyPass /berat http://127.0.0.1:3000/berat > ProxyPassReverse /berat http://127.0.0.1:3000/berat > > ProxyPass /berat/ http://127.0.0.1:3000/berat/ > ProxyPassReverse /berat/ http://127.0.0.1:3000/berat/ > > all of these, oin other words, everything I'ver tried gets the same > weird behavior.. > the initial url is > http://161.35.5.174/berat > > after testing the url, the url is changed to > http://161.35.5.174 > > and i get the "403 forbidden" > > As far as I can tell in the errolog, i see the "No matching > DirectoryIndex...." entry.. > > I've also tried "<Location" blocks, as well as "<Proxy" blocks per > some sights I've seen.. > > I'm missing something that's subtle.. or that I just haven't seen. > > ps.. and yes, a while ago, i did manage to somehow get this to work.. > but when I was check ing my test scenario, it appears I had multiple > test config files, which may have conflicted.. (didn't think that was > possible though.) So I cleared out everything, and only have this > "berat.conf" as the only enabled file. > > any pointers/thoughts/comments.. i'll try. > > this is weird.. > thanks > > ps. i can even allow access to the test srever if need be. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx