Hi,I have added the below ProxyPassMatch and ProxyPassReverse in /etc/httpd/conf.d/phpnodejs.conf after referring to https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypassmatchProxyPassMatch "/demo(.*)" "http://localhost:8000/$1"
ProxyPassReverse "/demo(.*)" "http://localhost:8000/$1"#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/cardium-version-1/web
DirectoryIndex index.php
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 /index.php !ProxyPassMatch "/demo(.*)" "http://localhost:8000/$1"
ProxyPassReverse "/demo(.*)" "http://localhost:8000/$1"
<Directory "/var/www/html/phpcode/cardium-version-1/web">
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride All
Require valid-user
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /var/www/html/phpcode/cardium-version-1/web/.htpasswd
</Directory>
</VirtualHost>When I hit https://phpnodejs.mydomain.com the html and php code it works perfectly along with loading the resources like js, css and html pages. Whereas when I hit https://phpnodejs.mydomain.com/demo (/demo) which is the node.js backend listening on port 8000, I see the below logs in /var/log/httpd/ssl_access_log/demo is the node.js backend service listening on port 8000.172.16.16.45 - - [04/Jul/2023:22:35:05 +0530] "GET /demo/element/index.html HTTP/1.1" 304 -
172.16.16.45 - - [04/Jul/2023:22:35:05 +0530] "GET /demo/element/vendor.js HTTP/1.1" 304 -
172.16.16.45 - - [04/Jul/2023:22:35:05 +0530] "GET /demo/element/demo/apic-build.js HTTP/1.1" 304 -
172.16.16.45 - drupaladmin [04/Jul/2023:22:35:05 +0530] "GET /__es-dev-server__/message-channel HTTP/1.1" 404 25657More details here -> http://sprunge.us/6DFmPx# apachectl -S
VirtualHost configuration:
*:443 phpnodejs.mydomain.com (/etc/httpd/conf.d/phpnodejs.conf:5)
*:80 is a NameVirtualHost
default server phpnodejs.mydomain.com (/etc/httpd/conf.d/phpnodejs.conf:1)
port 80 namevhost phpnodejs.mydomain.com (/etc/httpd/conf.d/phpnodejs.conf:1)
port 80 namevhost phpnodejs.mydomain.com (/etc/httpd/conf.d/phpnodejs.conf:1)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/ssl_error_log"
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex cache-socache: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
#Please guide me. Thanks in advance.Best Regards,KaushalOn Mon, Jul 3, 2023 at 10:54 PM Kaushal Shriyan <kaushalshriyan@xxxxxxxxx> wrote:On Mon, Jul 3, 2023 at 10:44 PM Richard <lists-apache@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Date: Monday, July 03, 2023 22:22:04 +0530
> From: Kaushal Shriyan <kaushalshriyan@xxxxxxxxx>
>
> On Mon, Jul 3, 2023 at 10:10 PM Richard wrote:
>
>>
>> > Date: Monday, July 03, 2023 20:35:36 +0530
>> > From: Kaushal Shriyan <kaushalshriyan@xxxxxxxxx>
>> >
>> > I have initiated a new thread to discuss the new issue. I am
>> > running node.js application on port 8000 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
>> >#
>> >
>> > *#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/cardium-version-1/web
>> > DirectoryIndex index.php
>> > 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 /index.php !
>> > ProxyPassMatch "^/(.+)$" "http://localhost:8000/$1"
>> >
>> > <Directory "/var/www/html/phpcode/cardium-version-1/web">
>> > DirectoryIndex index.html index.php
>> > Options FollowSymLinks
>> > AllowOverride All
>> > Require valid-user
>> > AuthType Basic
>> > AuthName "Restricted Content"
>> > AuthUserFile
>> > /var/www/html/phpcode/cardium-version-1/web/.htpasswd
>> > </Directory> </VirtualHost>
>> >
>> > When I hit https://phpnodejs.mydomain.com it works perfectly
>> > fine. But when I click on any of the links on the home page
>> > which adds /en at the end of all the links, I get Not Found on
>> > the browser for all the links.
>> >
>> > For example https://https://phpnodejs.mydomain.com/en returns Not
>> > Found. https://
>> > https://phpnodejs.mydomain.com/en/community/webinars returns Not
>> > Found.
>> > https://phpnodejs.mydomain.com/en/community/articles returns Not
>> > Found.
>> >
>> > When I hit https://phpnodejs.mydomain.com/nodejssl/server.js
>> > works perfectly fine as expected.
>> >
>> > [image: image.png]
>> >
>> > cat /var/log/httpd/ssl_access_log
>> > 172.16.16.45 - - [03/Jul/2023:20:09:27 +0530] "GET
>> > /en/community/webinars HTTP/1.1" 404 9
>> > 172.16.16.45 - - [03/Jul/2023:20:09:35 +0530] "GET
>> > /en/apis/use-cases HTTP/1.1" 404 9
>> > 172.16.16.45 - - [03/Jul/2023:20:09:45 +0530] "GET
>> > /en/support/contact-us HTTP/1.1" 404 9
>> > 172.16.16.45 - - [03/Jul/2023:20:10:02 +0530] "-" 408 -
>> > 172.16.16.45 - - [03/Jul/2023:20:09:12 +0530] "GET
>> > /__es-dev-server__/message-channel HTTP/1.1" 200 30
>> > 172.16.16.45 - drupaladmin [03/Jul/2023:20:11:00 +0530] "GET /
>> > HTTP/1.1" 200 45339
>> > 172.16.16.45 - - [03/Jul/2023:20:11:03 +0530] "GET
>> > /en/community/webinars HTTP/1.1" 404 9
>> > 172.16.16.45 - - [03/Jul/2023:20:11:09 +0530] "GET
>> > /en/apis/use-cases HTTP/1.1" 404 9
>> > 172.16.16.45 - - [03/Jul/2023:20:11:11 +0530] "GET /en HTTP/1.1"
>> > 404 9 172.16.16.45 - - [03/Jul/2023:20:11:29 +0530] "-" 408 -
>> >
>>
>> You need to make some efforts to debug things yourself. Start by
>> looking in the *appropriate* error_log file for the entries
>> *matching* the above access_log 404s. I suspect that that could
>> enlighten you.
>>
>>
>>
>> ------------------------------------------------------------------
>> --- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For
>> additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>>
>>
> Thanks Richard for the hint and appreciate it. Using the below
> config file while commenting both ProxyPass and ProxyPassMatch
> directive it works perfectly fine.
>
># ProxyPass /index.php !
># ProxyPassMatch "^/(.+)$" "http://localhost:8000/$1"
>
. . .
>
> I will continue to debug and analyse the cause of the "Not Found"
> issue. Thanks in advance.
>
Look at, and understand, the implications of the syntax of those
proxypass lines in the context of where your content is. The
documentation page referenced previously:
<https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypassmatch>
should help. Are the pages that you are getting 404s on on the proxy?
Thanks Richard for the quick response. When I enable the below, I encounter 404 while hitting the main webpage https://phpnodejs.mydomain.com/en.<Directory "/var/www/html/phpcode/cardium-version-1/web"> as per /etc/httpd/conf.d/phpnodejs.conf# pwd
/var/www/html/phpcode/cardium-version-1/web
# ls -ltotal 36
-rw-rw-r-- 1 apache apache 315 May 15 18:21 autoload.php
drwxrwxr-x 12 apache apache 4096 Apr 26 18:23 core
-rw-rw-r-- 1 apache apache 1507 Mar 8 19:40 example.gitignore
-rw-rw-r-- 1 apache apache 549 Mar 8 19:40 index.php
-rw-rw-r-- 1 apache apache 94 Mar 8 19:40 INSTALL.txt
drwxrwxr-x 4 apache apache 52 Apr 11 20:51 libraries
drwxrwxr-x 5 apache apache 75 Mar 8 19:38 modules
drwxrwxr-x 2 apache apache 24 Mar 8 19:16 profiles
-rw-rw-r-- 1 apache apache 3205 Mar 8 19:16 README.md
-rw-rw-r-- 1 apache apache 1706 Apr 27 22:33 robots.txt
drwxrwxr-x 3 apache apache 130 Mar 8 19:40 sites
drwxrwxr-x 4 apache apache 53 Mar 8 19:39 themes
-rw-rw-r-- 1 apache apache 804 Mar 8 19:40 update.php
-rw-rw-r-- 1 apache apache 4039 Mar 8 19:40 web.config
#Is there a way to enable debug logs for ProxyPass and ProxyPassMatch directive?Please suggest and guide me. Thanks in advance.Best Regards,Kaushal