logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Help - virtual host throwing 400 error
Author
VdtsCoder



Joined: 02 May 2023
Posts: 5
Location: US

PostPosted: Tue 02 May '23 20:55    Post subject: Help - virtual host throwing 400 error Reply with quote

I have a domain aecperformance.com hosted on a Debian vps running apache2.
There are actually 4 domains total and 3 sub domains under aecperformance.com: app.aecperformance.com; dev.aecperformance.com; api.aecperformance.com.

Everything works except api.aecperformance.com which throws the 400 error.

I can do a dns lookup on api.aecperformance.com and the domain looks correct.
If I wget https://api.aecperformance.com from within the server terminal, I get the same 400 error.

if I run: sudo a2ensite api.aecperformance.com
it returns: Site api.aecperformance.com already enabled

If I run: sudo apachectl configtest
it returns: Syntax OK

Notice below that I named the log files api.error.log and api.access.log.
Those files were generated proving that the conf file was read by apache.
api.error.log is empty, api.access.log shows basic connection information for robots.txt and for index.php.
robots.txt is non-existent.




What is causing the 400 error? Why can't I see the site?

The config file is:
Code:

<VirtualHost *:80>
    ServerAdmin mailadm@aecperformance.com
    ServerName api.aecperformance.com   
    DocumentRoot /var/www/api.aecperformance.com
    <Directory "/var/www/api.aecperformance.com">
      Options FollowSymLinks
      AllowOverride All
        Options -Indexes
        Require all granted
    </Directory>
    DirectoryIndex index.php
    ErrorLog ${APACHE_LOG_DIR}/api.error.log
    CustomLog ${APACHE_LOG_DIR}/api.access.log combined
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =api.aecperformance.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>


The file /var/www/api.aecperformance.com/index.php is:
Code:

<html>
   <head>
      <title>Test API</title>
   </head>
   <body>
      test from API
   </body>
</html>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7374
Location: Germany, Next to Hamburg

PostPosted: Wed 03 May '23 10:04    Post subject: Reply with quote

There is a rewrite rule to force ssl/https. Did you configure a SSL vhost for that domain?
Back to top
VdtsCoder



Joined: 02 May 2023
Posts: 5
Location: US

PostPosted: Wed 03 May '23 13:55    Post subject: Reply with quote

James Blond: thanks for responding.

Yes api.aecperformance.com does have a valid certificate.
If you try to open the url with your browser and click the lock you'll see that the certificate is valid.
Also, if you try to connect to: http://api.aecperformance.com you will be redirected to https://api.aecperformance.com.
This again proves that the conf file is being read by apache.

It didn't matter though. I've tried multiple variations on the conf file. All of them return the 400 error.

The first variation was this:
Code:

<VirtualHost *:80>
    ServerAdmin mailadm@aecperformance.com
    ServerName api.aecperformance.com   
    DocumentRoot /var/www/api.aecperformance.com   
    DirectoryIndex index.php
    ErrorLog ${APACHE_LOG_DIR}/api.error.log
    CustomLog ${APACHE_LOG_DIR}/api.access.log combined   
</VirtualHost>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7374
Location: Germany, Next to Hamburg

PostPosted: Wed 03 May '23 18:42    Post subject: Reply with quote

Replace the index.php with a index.html and simple content to make sure that it works. If yes we may have to take a look at your PHP configuration in your apache c condig
Back to top
VdtsCoder



Joined: 02 May 2023
Posts: 5
Location: US

PostPosted: Wed 03 May '23 19:10    Post subject: Reply with quote

Thanks again for responding.
It turns out that the problem was with the certificate.

It's fixed now so we're past the 400 error.
Thanks for your help.
Back to top


Reply to topic   Topic: Help - virtual host throwing 400 error View previous topic :: View next topic
Post new topic   Forum Index -> Apache