0

I have installed and configured Wordpress on my server using also apach2 virtualhosts. I made a virtualhost with this config

<VirtualHost *:80 *:443>

    ServerAdmin [email protected]
    ServerName yourluxuryroad.com
    ServerAlias www.yourluxuryroad.com
    DocumentRoot /var/www/yourluxuryroad
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine on
    RewriteCond %{SERVER_NAME} =www.yourluxuryroad.com [OR]
    RewriteCond %{SERVER_NAME} =yourluxuryroad.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass /node-yrl-book http://localhost:5000
    ProxyPassReverse /node-yrl-book http://localhost:5000

</VirtualHost>

<Directory /var/www/yourluxuryroad/>
    AllowOverride All
</Directory>

As you can see from the config i'm trying to set the ProxyPass directive for redirect the requests recived on the path /node-yrl-book to a nodejs service ( made using expressjs ) at port 5000 but this is not working, instead of getting a redirect to that service i get the 404 Page not found wordpress page.

If I make a request at my_ip/node-yrl-book instead it works correctly and i am redirected to the service at port :5000

I suppose that i'm missing something in my configuration but i'm not understanding what.. Maybe is something in wordpress that has to be changed?

2 Answers 2

1

You placed your ProxyPass directives in the VirtualHost for Port 80, which redirects to HTTPS.

Place the ProxyPass directives into the VirtualHost for HTTPS.

6
  • I have updated the .config file as you said ( i think ) and reloaded apache but it still does the same issue.I made the same changes in the answer
    – Mat.C
    Oct 4, 2020 at 16:45
  • Actually that page is the Wordpress 'Not found' Page, not the one from apache or express, so i don't know if this has something to do with wordpress that 'deny' the redirect or is apache
    – Mat.C
    Oct 4, 2020 at 16:51
  • Wait, did you create an additional VirtualHost? So you have two VirtualHosts for the same ServerName? You can only have one. Add the Proxy directives to your existing config, instead of creating a second one. Oct 4, 2020 at 16:54
  • Sorry but i started like yeasterday to play with apache and i'm a bit confused, i have this file called yourluxuryroad.conf and inside this one i made all the changes, you want me to delete de *:443 virtual host and add the directives in the first one?
    – Mat.C
    Oct 4, 2020 at 16:57
  • You need to make sure that you have one VirtualHost block (for each :80 and :443) for your server name. There is nothing in your config that looks wrong, usually that means that somewhere in the Apache config exists another VirtualHost block that overrides this config. Oct 4, 2020 at 17:04
0

Finally i solved this, I made an SSL certificate for my website using let's encrypt certbot, This script created a new virtualhost in another file for the https requests ( called /etc/apache2/sites-available/myDomain-le-ssl.conf ) That virtualhost was overriding my proxypass directive, editing also this virtualhost made all work

1
  • so if you use certbot this is how i managed to solve my problem
    – Mat.C
    Oct 5, 2020 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .