Hi,

I have set up a new server with the below details. I am running node.js
application on port 3000 and Apache HTTP server on CentOS Linux release
7.9.2009 (Core)

# node --version
*v16.20.0*
# httpd -v
Server version: *Apache/2.4.57 (IUS)*
Server built:   Apr  7 2023 14:49:47
#

*Nodejs code document root -> /var/www/html/nodejssl (Node Port 3000)*
# pwd
/var/www/html/nodejssl
# ls -l
-rw-r--r-- 1 root root 336 Jun 27 09:43 server.js
#
*cat server.js*
const http = require('http');

const hostname = '0.0.0.0';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});


*Website php code document root -> /var/www/html/phpcode (Port 443)*

#pwd
/var/www/html/phpcode/
# ls -l
-rw-r--r-- 1 root root 336 Jun 27 09:43 index.html
#
#cat index.html
<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <title>Hello!</title>
    </head>

    <body>
        <h1>Hello World!</h1>
        <p>This is a simple paragraph.</p>
    </body>

</html>

#cat /etc/httpd/conf.d/phpnodejs.conf
<VirtualHost *:80>
    ServerName phpnodejs.mydomain.com
    Redirect / https://phpnodejs.mydomain.com/
 </VirtualHost>
<VirtualHost *:443>
        DocumentRoot /var/www/html/phpcode
        ServerName phpnodejs.mydomain.com
        Header add Access-Control-Allow-Origin "*"
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/
phpnodejs.mydomain.com/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/
phpnodejs.mydomain.com/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/
phpnodejs.mydomain.com/chain.pem
        Header always set Strict-Transport-Security "max-age=63072000;
includeSubDomains"
        ProxyPass / http://localhost:3000/
</VirtualHost>

When i hit https://phpnodejs.mydomain.com/nodejssl/server.js I see "Hello
World" which works as expected but when i hit
https://phpnodejs.mydomain.com/ I do not see the html code index.html file
content. Is there a way to render both index.html and node.js server.js
file? For example when i hit https://phpnodejs.mydomain.com/ it renders
index.html file content and when i hit
https://phpnodejs.mydomain.com/nodejssl/server.js it renders node.js
server.js file content.

Please suggest and guide me. Thanks in advance.

Best Regards,

Kaushal

On Sun, Jun 25, 2023 at 10:13 PM Frank Gingras <thu...@apache.org> wrote:

> None of those entries point to your 404 error.
>
> Make sure that you are reaching the proper vhost (with the scheme and
> hostname) by running apachectl -S.
>
> There is just far too much noise in the backlog of this thread to make
> sense of it so far.
>
> On Sun, Jun 25, 2023 at 11:46 AM Richard <
> lists-apa...@listmail.innovate.net> wrote:
>
>>
>>
>>
>> > Date: Sunday, June 25, 2023 16:09:23 +0530
>> > From: Kaushal Shriyan <kaushalshri...@gmail.com>
>> >
>> > I have modified the nodejsbackendssl.conf file located
>> > in /etc/httpd/conf.d/ to the below configuration.
>> >
>> > *#cat  /etc/httpd/conf.d/nodejsbackendssl.conf*
>> > <VirtualHost *:80>
>> >         ServerName nodejs.mydomain.com
>> >         ProxyPass / http://localhost:8000/
>> >         LogLevel debug
>> >         ErrorLog /var/log/httpd/nodejssslerror.log
>> >         CustomLog /var/log/httpd/nodejssslaccess.log combined
>> > </VirtualHost>
>> >
>> > Below are the logs in /var/log/httpd/nodejssslerror.log
>> >
>> > [Sun Jun 25 16:04:40.289171 2023] [proxy:debug] [pid 6223:tid 6223]
>> >> proxy_util.c(2155): AH00925: initializing worker
>> >> http://localhost:8000/ shared
>>
>> If you are still getting errors (e.g., 404s) on the front-end please
>> provide the relevant lines from the front-end server's error_log. The
>> proxy's corresponding log entries may be of value, but without the
>> detail from the front-end it's hard to tell.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
>> For additional commands, e-mail: users-h...@httpd.apache.org
>>
>>

Reply via email to