• Resolved linch1

    (@linch1)


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

    
    <VirtualHost *:80>
    
        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>
    
    <VirtualHost *:443>
        ServerName yourluxuryroad.com
        ServerAlias www.yourluxuryroad.com
        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?

    • This topic was modified 5 years, 8 months ago by linch1.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter linch1

    (@linch1)

    I have update the config as following becouse the upper one was wrong, but still got the same issue

    
    <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>
    
    
    Dion

    (@diondesigns)

    Since WordPress is using rewrite rules in a specific directory, those take precedence over your global proxy directives. I believe you must enclose the proxy directives in a <Location> block to override the rewrite rules. Example:

    <Location "/node-yrl-book">
    	ProxyPass http://localhost:5000
    	ProxyPassReverse http://localhost:5000
    </Location>
    Thread Starter linch1

    (@linch1)

    Thanks for the suggestion, I updated the config as you said but unfortunately still get the wordpres 404 not found page

    
    <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
    
        <Location "/node-yrl-book">
            ProxyPass http://localhost:5000
            ProxyPassReverse http://localhost:5000
        </Location>
    
    </VirtualHost>
    
    <Directory /var/www/yourluxuryroad/>
        AllowOverride All
    </Directory>
    
    • This reply was modified 5 years, 8 months ago by linch1.
    Thread Starter linch1

    (@linch1)

    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

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘( Ubunutu 20 ) Apache2 Proxypass with wordpress’ is closed to new replies.