(Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post your questions about Web Server usage and Apache + PHP + MySQL/SQLite web applications.
Post Reply
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

(Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

This seems to be a recurring issue with QNAP since years and I am stymied as I must be overlooking something that should jump in my face. Or am I?

I seem to be unable to use the virtual host functionality. I would appreciate some help to find how to get the virtual host show my websites instead of the index.php in /Web.

Setup:

I have two sites using WordPress, one in the default location /share/CE_CACHEDEV1_DATA/Web/WordPress and the other one in a subdirectory of /share/CE_CACHEDEV1_DATA/Web/wp-tmd/wordpress (separately installed but using the same database).

The virtual host is running listening on ports 8082 and 8083 pointing to these directories, each one having their respective index.php at the ready.

When connecting from the web, the result is always showing the /share/CE_CACHEDEV1_DATA/Web/index.php content (which I have edited to show the same lovely picture as pwilson has kindly mentioned, in order to avoid the recurring redirect to the QNAP admin access screen.
Just adding some info for better understanding. This is the content of the httpd-ssl-vhosts-user.conf, that my QNAP generated:

Code: Select all

NameVirtualHost *:8082

Listen 8082

<VirtualHost *:8082>
<Directory "/share/Web/WordPress">
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName REDACTED.ch
DocumentRoot "/share/Web/WordPress"
SSLEngine on
SSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:!MD5
SSLProtocol All -SSLv2 -SSLv3
SSLCertificateFile "/etc/stunnel/stunnel.pem"
</VirtualHost>
A curl to port 8082 results in:

Code: Select all

curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
a curl -v https://REDACTED.ch:8081 results in

Code: Select all

* Rebuilt URL to: https://REDACTED.ch:8081/
* Trying 37.24.108.230...
* TCP_NODELAY set
* Connected to REDACTED.ch (xx.xx.xx.xx) port 8081 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=REDACTED.ch
* start date: Aug 12 21:06:00 2019 GMT
* expire date: Nov 10 21:06:00 2019 GMT
* subjectAltName: host "REDACTED.ch" matched cert's "REDACTED.ch"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x562a4f74fda0)
> GET / HTTP/1.1
> Host: rothpartners.ch:8081
> User-Agent: curl/7.52.1
> Accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200 
< date: Tue, 13 Aug 2019 11:29:58 GMT
< server: Apache
< x-frame-options: SAMEORIGIN
< vary: Accept-Encoding
< content-type: text/html; charset=UTF-8
< 
* Curl_http_done: called premature == 0
* Connection #0 to host REDACTED.ch left intact
<img src="http://i40.tinypic.com/avqurc.gif" border=0>
I was expecting the wordpress sites to come up, but instead the /Web/index.php is called (showing the Gif mentioned by pwilson in an earlier thread).

What am I doing wrong?

(TVS 473, FW 4.3.6.0993)
User avatar
Toxic17
Ask me anything
Posts: 6477
Joined: Tue Jan 25, 2011 11:41 pm
Location: Planet Earth
Contact:

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by Toxic17 »

azaroth01 wrote: Wed Aug 14, 2019 3:20 pm This seems to be a recurring issue
indeed it is

viewtopic.php?f=32&t=149194&p=723564#p723564

viewtopic.php?f=32&t=64143&p=723503#p723529

and I replied to you.

viewtopic.php?f=32&t=64143&p=723529#p723569

viewtopic.php?f=32&t=149194&p=723564#p723568

are we really going around in circles?

Anyway.
When connecting from the web, the result is always showing the /share/CE_CACHEDEV1_DATA/Web/index.php
when "connecting from the web", you should have http://domainname/index.php in a browser. how are you seeing /share/CE_CACHEDEV1_DATA/Web/ in your browser? are you connecting to your website locally from the same LAN?

the index.php file in the web folder as a default file (from QNAP) will redirect to the WebGui of the NAS. either add a redirect or remove it. one or the other.

you can also call other files using the ".htaccess" file which you may have in your wordpress root folders.

Also are you using the built in webserver or using something like QAPACHE or Apache73 as the web Server?

I'll move onto virtual hosts when you acknowledge my reply.
Regards Simon

Qnap Downloads
MyQNap.Org Repository
Submit a ticket • QNAP Helpdesk
QNAP Tutorials, User Manuals, FAQs, Downloads, Wiki
When you ask a question, please include the following


NAS: TS-673A QuTS hero h5.1.2.2534 • TS-121 4.3.3.2420 • APC Back-UPS ES 700G
Network: VM Hub3: 500/50 • UniFi UDM Pro: 3.2.9 • UniFi Network Controller: 8.0.28
USW-Aggregation: 6.6.61 • US-16-150W: 6.6.61 • 2x USW Mini Flex 2.0.0 • UniFi AC Pro 6.6.62 • UniFi U6-LR 6.6.62
UniFi Protect: 2.11.21/8TB Skyhawk AI • 3x G3 Instants: 4.69.55 • UniFi G3 Flex: 4.69.55 • UniFi G5 Flex: 4.69.55
User avatar
Toxic17
Ask me anything
Posts: 6477
Joined: Tue Jan 25, 2011 11:41 pm
Location: Planet Earth
Contact:

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by Toxic17 »

a curl -v https://REDACTED.ch:8081 results in
but your virtual hosts were on port 8082 and 8083 as stated by you. I'm not sure why you are now using 8081?

tbh we need to get a working website up first of all. it is pointless trying to setup two domains when it appears neither of them are working and your trying to use two different ports for two different domains. with Vhosts you call both sites urls on the same port. a request for a domain just read the vhosts file and matches where the folder is.

example of two domains in a vhost file. (no https)

Code: Select all

# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
    DocumentRoot "/www/example1"
    ServerName www.example.com

    # Other directives here
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/www/example2"
    ServerName www.example.org

    # Other directives here
</VirtualHost>
now when a request comes to your WAN IP address for http://mydomain.com (port 80 by default) your router will port forward port 80 to the NAS. the NAS will see a request for mydomain.com and forward that to the

DocumentRoot "/share/Web/WordPress"

is a request come in for myotherdomain.com (port 80 again) then the NAS responds with

DocumentRoot "/share/Web/WordPress1234"

no other ports needed to be used.

you external wan ports should always be port 80 (http) and port 443 (https).

if you use separate ports internally you cannot the port forward the external port to two different ports on the inside. ie port 80(WAN) going to ports 8082 AND 8083. it wont work. hense vhosts file decides where domain name requests are directed to what folder.

more info here: https://httpd.apache.org/docs/2.4/vhosts/examples.html

btw I found the built in Web Server limiting and outdated when I used it. it is more upto date now but still has limiting factors about it which a full blown Apache/PHP server like QApache and Apache73 QPKGs offer.
Regards Simon

Qnap Downloads
MyQNap.Org Repository
Submit a ticket • QNAP Helpdesk
QNAP Tutorials, User Manuals, FAQs, Downloads, Wiki
When you ask a question, please include the following


NAS: TS-673A QuTS hero h5.1.2.2534 • TS-121 4.3.3.2420 • APC Back-UPS ES 700G
Network: VM Hub3: 500/50 • UniFi UDM Pro: 3.2.9 • UniFi Network Controller: 8.0.28
USW-Aggregation: 6.6.61 • US-16-150W: 6.6.61 • 2x USW Mini Flex 2.0.0 • UniFi AC Pro 6.6.62 • UniFi U6-LR 6.6.62
UniFi Protect: 2.11.21/8TB Skyhawk AI • 3x G3 Instants: 4.69.55 • UniFi G3 Flex: 4.69.55 • UniFi G5 Flex: 4.69.55
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

Hi Simon

thanks for the quick response.

Just let me confirm first that both WordPress installations are running and up, I can access and edit them on the local network. Coming from outside, I am getting an URL not found (404) error with the domains. Hence I used curl from a Linux server on the network to check the response in detail, also using port 8081. I do see the site from outside when entering

https://REDACTED.ch:8081/wp-tmd/wordpress/ .

So I do assume that is working as documented. I am just flabbergasted that the virtual hosts don't divert the traffic to the subdirectories in question as expected, but I realize that it's me not QNAP. I just don't see my error.

I am not using HTTP at all (only HTTPS).

Let me read your info and I will come back when I have digested your kind info.

cheers!
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

Allright, Simon

I have worked through your recommendations and links and have continued to check on my possible mistakes. Here's my take-out of these changes and experiments: The virtual hosts, in spite of having their SSL config representing what I would expect, do not work as intended by me (which may mean they work as intended by the makers, and I just don't dig it).

I have reduced my analysis to one of the two WordPress websites, which should respond to traffic directed to port 8083.

Incoming HTTPS-traffic is rerouted from port 443 to port 8083. QNAP is not pointing it to the directory they should go to (/Web/wp-tmd/wordpress), but to the /Web folder and manages to transfer it to port 8081, displaying the index.php there. I have replaced the index.php to display a gif (see pwilsons post about it).

I am using the built-in apache, not an add-on as I am trying to stick as much as possible to the standard.

The traffic is also immediately rerouted to port 8081 by the Webserver. I cannot access the subdirectories in order to see the web-pages from outside.

From within my local network, accessing the site is possible, albeit it is always redirected to port 8081. I end up for example on

https://xx.xx.xx.xx:8081/wp-tmd/wordpress/wp-admin/

This leads me to the assumption that something in the virtual hosts thingy is not working or that I need to do something else to make it work as expected.

Any ideas to resolve this are appreciated.
User avatar
Toxic17
Ask me anything
Posts: 6477
Joined: Tue Jan 25, 2011 11:41 pm
Location: Planet Earth
Contact:

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by Toxic17 »

in your wordpress setup there should be a wordpress address (URL) fields. this needs to be your FQDN (domain name) and not the local IP address can you confirm this is the case?
Regards Simon

Qnap Downloads
MyQNap.Org Repository
Submit a ticket • QNAP Helpdesk
QNAP Tutorials, User Manuals, FAQs, Downloads, Wiki
When you ask a question, please include the following


NAS: TS-673A QuTS hero h5.1.2.2534 • TS-121 4.3.3.2420 • APC Back-UPS ES 700G
Network: VM Hub3: 500/50 • UniFi UDM Pro: 3.2.9 • UniFi Network Controller: 8.0.28
USW-Aggregation: 6.6.61 • US-16-150W: 6.6.61 • 2x USW Mini Flex 2.0.0 • UniFi AC Pro 6.6.62 • UniFi U6-LR 6.6.62
UniFi Protect: 2.11.21/8TB Skyhawk AI • 3x G3 Instants: 4.69.55 • UniFi G3 Flex: 4.69.55 • UniFi G5 Flex: 4.69.55
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

Toxic17 wrote: Wed Aug 14, 2019 8:51 pm in your wordpress setup there should be a wordpress address (URL) fields. this needs to be your FQDN (domain name) and not the local IP address can you confirm this is the case?
yes, can confirm that.
User avatar
Toxic17
Ask me anything
Posts: 6477
Joined: Tue Jan 25, 2011 11:41 pm
Location: Planet Earth
Contact:

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by Toxic17 »

the built in apache is doing this the vast majority of the redirect. please post the contents of the Web/index.php file in a code bracket or attach it here.

also any files other than index.php in the /Web/ folder?

the other thing is the permissions might not be correct on the /Web/ sub folders. can you confirm "httpdusr [99]" (this is the apache owner) is the owner of these folders?

the other thing, just in case you havent seen it: https://www.qnap.com/en/how-to/tutorial ... l-hosting/

I definitely used this in the past and it just worked. Though I do not use wordpress and vhosts any longer.

if all settings are virtually similar as to the examples then their maybe something broken in the built in webserver/virtual host section and QNAP may need to be informed of the issue.

I can probably fire up somethings over the next few days on the 473 to test this method works or not.
Regards Simon

Qnap Downloads
MyQNap.Org Repository
Submit a ticket • QNAP Helpdesk
QNAP Tutorials, User Manuals, FAQs, Downloads, Wiki
When you ask a question, please include the following


NAS: TS-673A QuTS hero h5.1.2.2534 • TS-121 4.3.3.2420 • APC Back-UPS ES 700G
Network: VM Hub3: 500/50 • UniFi UDM Pro: 3.2.9 • UniFi Network Controller: 8.0.28
USW-Aggregation: 6.6.61 • US-16-150W: 6.6.61 • 2x USW Mini Flex 2.0.0 • UniFi AC Pro 6.6.62 • UniFi U6-LR 6.6.62
UniFi Protect: 2.11.21/8TB Skyhawk AI • 3x G3 Instants: 4.69.55 • UniFi G3 Flex: 4.69.55 • UniFi G5 Flex: 4.69.55
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

Toxic17 wrote: Wed Aug 14, 2019 10:14 pm the built in apache is doing this the vast majority of the redirect. please post the contents of the Web/index.php file in a code bracket or attach it here.

Code: Select all

<?php
echo "<img src=\"http://i40.tinypic.com/avqurc.gif\" border=0>";
?>
Toxic17 wrote: Wed Aug 14, 2019 10:14 pmalso any files other than index.php in the /Web/ folder?
a backup copy of the original file redirecting to the admin-login, which I renamed (non-functional).
Toxic17 wrote: Wed Aug 14, 2019 10:14 pmthe other thing is the permissions might not be correct on the /Web/ sub folders. can you confirm "httpdusr [99]" (this is the apache owner) is the owner of these folders?
httpdusr:guest is owner. E.g.

Code: Select all

 drwxrwxrwx  9 httpdusr guest           4096 2019-08-12 17:10 wp-admin/
cheerio
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

Update: I removed PHP and Wordpress, reinstalled it and reinstalled the backup of the site. Removed all instances of virtual hosts and removed/reinstated the Web-Server. No dice. I am still / again redirected to 8081. Must be the virtual host.

Okay. I am ready to try out experimental stuff to get around this. Should I try a LAMP-stack VM with a separate Ethernet-cable hooked to a different port and dedicated to the website?

In the meantime it took me about 30 minutes to redirect the DNS and reinstall one of the two sites to a provider as I needed the this to be online really hard. Will take it back when I manage the QNAP.
User avatar
Toxic17
Ask me anything
Posts: 6477
Joined: Tue Jan 25, 2011 11:41 pm
Location: Planet Earth
Contact:

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by Toxic17 »

sorry You say you removed php? php is built into QTS firmware which is then part of the webserver along with Apache.

are you using a separate PHP installed package? I'm now confused.
Regards Simon

Qnap Downloads
MyQNap.Org Repository
Submit a ticket • QNAP Helpdesk
QNAP Tutorials, User Manuals, FAQs, Downloads, Wiki
When you ask a question, please include the following


NAS: TS-673A QuTS hero h5.1.2.2534 • TS-121 4.3.3.2420 • APC Back-UPS ES 700G
Network: VM Hub3: 500/50 • UniFi UDM Pro: 3.2.9 • UniFi Network Controller: 8.0.28
USW-Aggregation: 6.6.61 • US-16-150W: 6.6.61 • 2x USW Mini Flex 2.0.0 • UniFi AC Pro 6.6.62 • UniFi U6-LR 6.6.62
UniFi Protect: 2.11.21/8TB Skyhawk AI • 3x G3 Instants: 4.69.55 • UniFi G3 Flex: 4.69.55 • UniFi G5 Flex: 4.69.55
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

Hi Simon
I removed PHPMyAdmin, not the database. Not sure what to do about the virtual hosts, though.
cheers
User avatar
Toxic17
Ask me anything
Posts: 6477
Joined: Tue Jan 25, 2011 11:41 pm
Location: Planet Earth
Contact:

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by Toxic17 »

I'll try replicating the issue over the weekend if I can

if you remove/rename the index.php from the Web folder, what happens.
Regards Simon

Qnap Downloads
MyQNap.Org Repository
Submit a ticket • QNAP Helpdesk
QNAP Tutorials, User Manuals, FAQs, Downloads, Wiki
When you ask a question, please include the following


NAS: TS-673A QuTS hero h5.1.2.2534 • TS-121 4.3.3.2420 • APC Back-UPS ES 700G
Network: VM Hub3: 500/50 • UniFi UDM Pro: 3.2.9 • UniFi Network Controller: 8.0.28
USW-Aggregation: 6.6.61 • US-16-150W: 6.6.61 • 2x USW Mini Flex 2.0.0 • UniFi AC Pro 6.6.62 • UniFi U6-LR 6.6.62
UniFi Protect: 2.11.21/8TB Skyhawk AI • 3x G3 Instants: 4.69.55 • UniFi G3 Flex: 4.69.55 • UniFi G5 Flex: 4.69.55
azaroth01
Starting out
Posts: 17
Joined: Tue Aug 13, 2019 5:38 pm

Re: (Q): hosting multiple WordPress sites. Virtual host not redirecting to subdirectories

Post by azaroth01 »

still redirected to port 8081, just that it's a 404.
Post Reply

Return to “Web Server & Applications (Apache + PHP + MySQL / SQLite)”