Hi Frank,I have tried the below configurations referring to https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypassreverse#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 !
ProxyPass /demo http://localhost:8000/demo
ProxyPassReverse /demo http://localhost:8000/demo
<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>Node.js document root# pwd
/var/www/html/api-console
# ll
total 1896
-rw-r--r-- 1 deployuser deployuser 151 Jun 21 23:57 api-console-app.d.ts
-rw-r--r-- 1 deployuser deployuser 121 Jun 21 23:57 api-console-app.js
-rw-r--r-- 1 deployuser deployuser 138 Jun 21 23:57 api-console.d.ts
-rw-r--r-- 1 deployuser deployuser 108 Jun 21 23:57 api-console.js
-rw-r--r-- 1 deployuser deployuser 1419 Jun 21 23:57 build-demo.html
-rw-r--r-- 1 deployuser deployuser 17438 Jun 21 23:57 CHANGELOG.md
-rw-r--r-- 1 deployuser deployuser 69 Jun 21 23:57 commitlint.config.js
-rw-r--r-- 1 deployuser deployuser 4113 Jun 21 23:57 CONTRIBUTING.md
drwxr-xr-x 9 deployuser deployuser 324 Jun 21 23:57 demo
drwxr-xr-x 2 deployuser deployuser 23 Jun 21 23:57 docs
-rw-r--r-- 1 deployuser deployuser 100 Jun 21 23:57 index.d.ts
-rw-r--r-- 1 deployuser deployuser 277 Jun 21 23:57 index.html
-rw-r--r-- 1 deployuser deployuser 106 Jun 21 23:57 index.js
-rw-r--r-- 1 deployuser deployuser 106 Jun 21 23:57 index.js.backup
-rw-r--r-- 1 deployuser deployuser 27135 Jun 21 23:57 LICENSE.md
-rw-r--r-- 1 deployuser deployuser 228 Jun 21 23:57 manifest.json
drwxr-xr-x 1011 deployuser deployuser 32768 Jun 21 23:57 node_modules
-rw-r--r-- 1 deployuser deployuser 4804 Jun 21 23:57 package.json
-rw-r--r-- 1 deployuser deployuser 1745688 Jun 21 23:57 package-lock.json
-rw-r--r-- 1 deployuser deployuser 2292 Jun 21 23:57 polymer.json
-rw-r--r-- 1 deployuser deployuser 7488 Jun 21 23:57 README.md
-rw-r--r-- 1 deployuser deployuser 1928 Jun 21 23:57 rollup.config.js
drwxr-xr-x 5 deployuser deployuser 51 Jun 21 23:57 screenshots
-rw-r--r-- 1 deployuser deployuser 351 Jun 21 23:57 sonar-project.properties
drwxr-xr-x 2 deployuser deployuser 282 Jun 21 23:57 src
drwxr-xr-x 2 deployuser deployuser 24 Jun 21 23:57 tasks
drwxr-xr-x 3 deployuser deployuser 280 Jun 21 23:57 test
-rw-r--r-- 1 deployuser deployuser 573 Jun 21 23:57 tsconfig.json
-rw-r--r-- 1 deployuser deployuser 920 Jun 21 23:57 web-test-runner.config.mjs
# cd demo/# ls -ltotal 376
-rw-r--r-- 1 deployuser deployuser 701 Jun 21 23:57 apic-build.js
-rw-r--r-- 1 deployuser deployuser 1977 Jun 21 23:57 api-console-demo-styles.css
-rw-r--r-- 1 deployuser deployuser 1935 Jun 21 23:57 apis.json
-rw-r--r-- 1 deployuser deployuser 7952 Jun 21 23:57 demo-base.js
drwxr-xr-x 3 deployuser deployuser 45 Jun 22 19:10 demo-server
drwxr-xr-x 2 deployuser deployuser 38 Jun 21 23:57 editor
drwxr-xr-x 2 deployuser deployuser 38 Jun 21 23:57 element
-rw-r--r-- 1 deployuser deployuser 1569 Jun 21 23:57 flattened-apis.json
drwxr-xr-x 2 deployuser deployuser 109 Jun 21 23:57 helpers
-rw-r--r-- 1 deployuser deployuser 2694 Jun 21 23:57 index.html
-rw-r--r-- 1 deployuser deployuser 130 Jun 21 23:57 index.js
-rw-r--r-- 1 deployuser deployuser 436 Jun 21 23:57 model.js
drwxr-xr-x 33 deployuser deployuser 4096 Jun 21 23:57 models
-rw-r--r-- 1 deployuser deployuser 1725 Jun 21 23:57 old.index.html
drwxr-xr-x 2 deployuser deployuser 38 Jun 21 23:57 standalone
drwxr-xr-x 2 deployuser deployuser 126 Jun 21 23:57 themed
-rw-r--r-- 1 deployuser deployuser 333832 Jun 21 23:57 vendor.js
# cd element/
# pwd/var/www/html/api-console/demo/element#ls -l
total 8
-rw-r--r-- 1 deployuser deployuser 3112 Jun 21 23:57 app.js
-rw-r--r-- 1 deployuser deployuser 2352 Jun 21 23:57 index.html
#I tried the below#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 !
ProxyPass /demo http://localhost:8000
ProxyPassReverse /demo http://localhost:8000
<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># apachectl -M | grep proxy
proxy_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_connect_module (shared)
proxy_express_module (shared)
proxy_fcgi_module (shared)
proxy_fdpass_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_hcheck_module (shared)
proxy_scgi_module (shared)
proxy_uwsgi_module (shared)
proxy_wstunnel_module (shared)
#Please guide me. Thanks in advance.Best Regards,KaushalOn Tue, Jul 4, 2023 at 10:53 PM Frank Gingras <thumbs@xxxxxxxxxx> wrote:This isn't how ProxyPassReverse is to be used, see:On Tue, Jul 4, 2023 at 1:21 PM Kaushal Shriyan <kaushalshriyan@xxxxxxxxx> wrote: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