Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
3 answers
6463 views
Multiple virtual host in Centos 7 is not working together
My server information is Server version: Apache/2.4.6 (CentOS) Server built: Nov 19 2015 21:43:13 I am trying to configure virtual host for 2 different sites: biz.example.com and pin.example.com which are hosted on the same server. There are 2 different folders located under 'var/www/html/' named 'b...
My server information is Server version: Apache/2.4.6 (CentOS) Server built: Nov 19 2015 21:43:13 I am trying to configure virtual host for 2 different sites: biz.example.com and pin.example.com which are hosted on the same server. There are 2 different folders located under 'var/www/html/' named 'biz' and 'pin' with their respected project files for the above mentioned 2 websites. I am trying to configure it on the below way. Within /etc/hosts below configuration 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 xxx.xxx.xxx.xxx biz.example.com xxx.xxx.xxx.xxx pin.example.com xxx.xxx.xxx.xxx is replaced by the server IP address. Within /etc/httpd/conf/httpd.conf IncludeOptional sites-enabled/*.conf Now, under /etc/httpd/sites-available there are biz.conf and pin.conf file. I also have the folder sites-enabled under /etc/httpd which has 2 files that points to the biz.conf and pin.conf of sites-available folder using the below command ln -s /etc/httpd/sites-available/biz.conf /etc/httpd/sites-enabled/biz.conf ln -s /etc/httpd/sites-available/pin.conf /etc/httpd/sites-enabled/pin.conf biz.conf has the followings ServerName http://biz.example.com/ ServerAlias http://biz.example.com/ DocumentRoot "/var/www/html/biz" Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Allow from 127.0.0.1 And the configuration within pin.conf file is mentioned as ServerName http://pin.example.com/ ServerAlias http://pin.example.com/ DocumentRoot "/var/www/html/pin" Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Allow from 127.0.0.1 On this setup, if i try to access http://biz.example.com/ , the correct website (biz website) is loading. But if i try to access http://pin.example.com/ , then also biz website is loading instead of pin website. Multiple configuration is not working together. I also tried to merge the virtual configuration of biz.conf and pin.conf within a single file, biz.conf, but it didn't work as well.
Debashis (111 rep)
Dec 16, 2016, 11:38 AM • Last activity: Jul 8, 2025, 02:07 PM
0 votes
1 answers
2028 views
How to detect the incoming httpd Connection Counts of each VHOSTS?
With RHEL and Apache (httpd), is there a way to: - Detect which v.host (domain) is gaining how many incoming connections? Because in this few days, I got a lot of incoming connections on the server being acknowledged by using: - `ps aux | grep httpd -c` 734 That means I have `734` incoming connectio...
With RHEL and Apache (httpd), is there a way to: - Detect which v.host (domain) is gaining how many incoming connections? Because in this few days, I got a lot of incoming connections on the server being acknowledged by using: - ps aux | grep httpd -c 734 That means I have 734 incoming connections currently being handled by Apache but the problem is I have (lets say) 10 Vhosts (domains). - So which domain is getting the high loads?
夏期劇場 (1671 rep)
Apr 22, 2014, 03:03 AM • Last activity: Oct 20, 2023, 09:01 PM
0 votes
0 answers
791 views
ocserv error: vhost, you cannot mix multiple authentication method
I'm trying to install [ocserv][1] *(OpenConnect VPN Server)*, using script from [this repository][2], on CentOS 8.1. Script automatically sets up server, certificate, user list and other settings. After `install.sh` is run *(script content is below)*, i check the logs using `journalctl -u ocserv`, a...
I'm trying to install ocserv *(OpenConnect VPN Server)*, using script from this repository , on CentOS 8.1. Script automatically sets up server, certificate, user list and other settings. After install.sh is run *(script content is below)*, i check the logs using journalctl -u ocserv, and this is the output:
Starting OpenConnect SSL VPN server...
Started OpenConnect SSL VPN server.
note: skipping 'pid-file' config option
error: cannot open file /etc/letsencrypt/live/208.xx.xx.xx/fullchain>
Parsing plain auth method subconfig using legacy format
error: vhost:default: you cannot mix multiple authentication method>
ocserv.service: Main process exited, code=exited, status=1/FAILURE
ocserv.service: Failed with result 'exit-code'.
Error seems to be error: vhost:default: you cannot mix multiple authentication method, which is located in the source code here . There is also this error error: cannot open file /etc/letsencrypt/live.. about certificate, not sure if it is important. Where is vhost:default config file (about multiple authentication) is located at & how to fix this? Or am i misinterpreting the errors? **PS**: *If you need output of any command, let me know in the comments* install.sh script
#!/bin/bash
# openconnect/anyconnect server (ocserv) installer in centos + let's ecnrypt 
# 
# bash install.sh -f username-list-file -n host-name -e email-address

usage()
{
    echo "usage:"
    echo "bash install.sh -f username-list-file -n host-name -e email-address"
}


###### Main

LIST=""
HOST_NAME=""
EMAIL_ADDR=""

if [[ $(dnf -q check-update | wc -l) > 0 ]] ; then
    echo 'You must be updated before this script.'
    echo 'Run: yum update'
    exit
fi

while [[ $1 != "" ]]; do
    case $1 in
        -f | --list )     shift
			        LIST=$1
                                ;;
        -n | --hostname )     shift
			        HOST_NAME=$1
                                ;;
        -e | --email )      shift
			        EMAIL_ADDR=$1
                                ;;
        -h | --help )         usage
                                exit
                                ;;
        * )                   usage
                                exit 1
    esac
    echo $1;
    shift
done

if [[ $HOST_NAME == "" ]] || [[ $EMAIL_ADDR == "" ]] || [[ $LIST == "" ]] ; then
  usage
  exit
fi

echo '[10%  ] Start installation...'
yum -q update -y  > /dev/null &
wait
yum install epel-release -y > /dev/null &
wait
yum repolist enabled > /dev/null &
wait
yum -q update --assumeno > /dev/null &
wait

yum install iptables-services -y > /dev/null &
wait

yum install ocserv certbot -y > /dev/null &
wait

echo '[20%  ] Request a valid certificate...'
certbot certonly --standalone --non-interactive --preferred-challenges http --agree-tos --email $EMAIL_ADDR -d $HOST_NAME &
wait

echo '[30%  ] Changing the default settings...'
sed -i 's/auth = "pam"/#auth = "pam"\nauth = "plain\[\/etc\/ocserv\/ocpasswd]"/' /etc/ocserv/ocserv.conf &
wait
sed -i 's/try-mtu-discovery = false/try-mtu-discovery = true/' /etc/ocserv/ocserv.conf &
wait
sed -i 's/#dns = 192.168.1.2/dns = 1.1.1.1\ndns = 8.8.8.8/' /etc/ocserv/ocserv.conf &
wait
sed -i 's/#tunnel-all-dns = true/tunnel-all-dns = true/' /etc/ocserv/ocserv.conf & # !=  = DNS Leak
wait
sed -i "s/server-cert = \/etc\/pki\/ocserv\/public\/server.crt/server-cert=\/etc\/letsencrypt\/live\/$HOST_NAME\/fullchain.pem/" /etc/ocserv/ocserv.conf &
wait
sed -i "s/server-key = \/etc\/pki\/ocserv\/private\/server.key/server-key=\/etc\/letsencrypt\/live\/$HOST_NAME\/privkey.pem/" /etc/ocserv/ocserv.conf &
wait
sed -i 's/ipv4-network = 192.168.1.0/ipv4-network = 192.168.2.0/' /etc/ocserv/ocserv.conf &
wait
sed -i 's/#ipv4-network = 192.168.1.0/ipv4-network = 192.168.2.0/' /etc/ocserv/ocserv.conf &
wait
sed -i 's/#ipv4-netmask = 255.255.255.0/ipv4-netmask = 255.255.255.0/' /etc/ocserv/ocserv.conf &
wait
sed -i 's/max-clients = 16/max-clients = 128/' /etc/ocserv/ocserv.conf &
wait
sed -i 's/max-same-clients = 2/max-same-clients = 4/' /etc/ocserv/ocserv.conf &
wait
#sed -i 's/#mtu = 1420/mtu = 1420/' /etc/ocserv/ocserv.conf &
#sed -i 's/#route = default/route = default/' /etc/ocserv/ocserv.conf & # for use server like gateway = IP Leak
sed -i 's/no-route = 192.168.5.0\/255.255.255.0/#no-route = 192.168.5.0\/255.255.255.0/' /etc/ocserv/ocserv.conf &
wait
#sed -i 's/udp-port = 443/#udp-port = 443/' /etc/ocserv/ocserv.conf & # if there is a problem with DTLS/UDP
wait

echo '[40%  ] Adding iptables items...'
iptables -I INPUT -p tcp --dport 22 -j ACCEPT & # SSH port
wait
iptables -I INPUT -p tcp --dport 443 -j ACCEPT &
wait
iptables -I INPUT -p udp --dport 443 -j ACCEPT &
wait
iptables -I INPUT -p udp --dport 53 -j ACCEPT &
wait
iptables -t nat -A POSTROUTING -j MASQUERADE &
wait
iptables -I FORWARD -d 192.168.2.0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT &
wait
iptables -A FORWARD -s 192.168.2.0 -j ACCEPT &
wait

echo '[50%  ] Activating the ip_forward feature...'
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf &
#echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf
wait

sysctl -p & # apply wihout rebooting
wait

echo '[60%  ] Adding users...'
echo ''
if [[ $LIST != "" ]] ; then
  while read -r -a line; do
    if [[ "${line}" != "" ]] ; then
      echo "   For user ${line} password updated with ${line[1] }"
      echo "${line[1] }" | ocpasswd -c /etc/ocserv/ocpasswd "${line}" &
      wait
    fi
  done  /dev/null &
wait
systemctl disable ocserv.socket > /dev/null &
wait

echo '[80%  ] Start ocserv service...'
systemctl restart ocserv.service > /dev/null &
wait
#systemctl status ocserv.service &
#wait

#iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT & # Allow SSH port. Is this port really configured?
#iptables -P INPUT DROP & # If you have not ACCEPT the SSH port connection before, do not run this command! 
#wait

echo '[90%  ] Persistent iptables rules...'
iptables-save > /etc/iptables.rules &
wait

systemctl enable iptables &
wait

service iptables save &
wait

systemctl start iptables &
wait

echo '[100% ] Your VPN server is ready to use.'
echo ''
echo 'Please check the ocserv logs with: journalctl -u ocserv'
echo ''
Jemshit (101 rep)
Jul 17, 2023, 04:09 PM
1 votes
0 answers
34 views
how make visual host in centos7 litespeed
My website show in port 8080 in server. How connect my domain name to `IPSERVER:8080` Server: CentOS 7 - Litespeed I have little information in this regard
My website show in port 8080 in server. How connect my domain name to IPSERVER:8080 Server: CentOS 7 - Litespeed I have little information in this regard
Mohammad reza Golshahi (111 rep)
May 14, 2022, 04:55 AM • Last activity: May 16, 2022, 11:45 AM
7 votes
2 answers
46989 views
Why is Apache running on port 8080 instead on port 80?
I am confused why Apache is not responding on port 80 ... $ wget http://localhost:80 --2014-05-06 15:32:44-- http://localhost/ Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused. ... but instead on post 8080 ... $ wget http://...
I am confused why Apache is not responding on port 80 ... $ wget http://localhost:80 --2014-05-06 15:32:44-- http://localhost/ Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused. ... but instead on post 8080 ... $ wget http://localhost:8080 --2014-05-06 15:32:38-- http://localhost:8080/ Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:8080... connected. HTTP request sent, awaiting response... 200 OK Length: 177 [text/html] Saving to: ‘index.html’ 100%[=================================================>] 177 --.-K/s in 0s 2014-05-06 15:32:38 (16,4 MB/s) - ‘index.html’ saved [177/177] Not too much too see in the output of *apache2ctl*: $ apache2ctl -t -D DUMP_VHOSTS VirtualHost configuration: *:80 is a NameVirtualHost default server localhost (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1) However, *netstat* confirms the port: $ sudo netstat -anp | grep :8080 tcp6 0 0 :::8080 :::* LISTEN 5353/apache2 --- As asked by Joel here is the ports.conf: $ sudo cat /etc/apache2/ports.conf # If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default Listen 8080 Listen 443 Listen 443 # vim: syntax=apache ts=4 sw=4 sts=4 sr noet # NameVirtualHost *:8800 Listen 8800
JJD (587 rep)
May 6, 2014, 01:40 PM • Last activity: Feb 21, 2022, 12:44 PM
0 votes
0 answers
622 views
Proftp Virtual Hosts Settings
i'm trying to set up proftpd with virtual server settings, but there are always problems during connection. I have two domains which are pointing to the same External IP Address: ftp.domain.tld -> 1.2.3.4 ftp1.domain.tld -> 1.2.3.4 The connection should go over TLS. So i created 2 virtual Server in...
i'm trying to set up proftpd with virtual server settings, but there are always problems during connection. I have two domains which are pointing to the same External IP Address: ftp.domain.tld -> 1.2.3.4 ftp1.domain.tld -> 1.2.3.4 The connection should go over TLS. So i created 2 virtual Server in the /etc/proftpd/proftpd.conf: ServerName "FTP Server" RequireValidShell no TransferLog /var/log/proftpd/xferlog.ftp MaxClients 50 DefaultServer on DefaultRoot ~ ftpuser AllowOverwrite yes TimeoutLogin 120 TimeoutIdle 600 TimeoutNoTransfer 900 DenyGroup !ftpuser TLSEngine on TLSLog /var/log/proftpd/tls.log TLSProtocol SSLv3 TLSRSACertificateFile /etc/letsencrypt/live/ftp.domain.tld/cert.pem TLSRSACertificateKeyFile /etc/letsencrypt/live/ftp.domain.tld/privkey.pem TLSCACertificateFile /etc/letsencrypt/live/ftp.domain.tld/chain.pem TLSVerifyClient no TLSRequired on TLSRenegotiate required off TLSOptions NoSessionReuseRequired ServerName "FTP 1 Server" RequireValidShell no TransferLog /var/log/proftpd/xferlog.ftp1 MaxClients 50 DefaultServer on DefaultRoot ~ ftpuser1 AllowOverwrite yes TimeoutLogin 120 TimeoutIdle 600 TimeoutNoTransfer 900 DenyGroup !ftpuser1 TLSEngine on TLSLog /var/log/proftpd/tls.log TLSProtocol SSLv3 TLSRSACertificateFile /etc/letsencrypt/live/ftp1.domain.tld/cert.pem TLSRSACertificateKeyFile /etc/letsencrypt/live/ftp1.domain.tld/privkey.pem TLSCACertificateFile /etc/letsencrypt/live/ftp1.domain.tld/chain.pem TLSVerifyClient no TLSRequired on TLSRenegotiate required off TLSOptions NoSessionReuseRequired When i try to connect i get the following Error Code: Antwort: 220 ProFTPD Server (ProFTPD Default Installation) Befehl: AUTH TLS Antwort: 500 AUTH not understood Befehl: AUTH SSL Antwort: 500 AUTH not understood Can someone help me? What i would like to do in the end is: - connect to this 2 domains with ssl connection - vhost 1 has its own users and directory - vhost 2 has its own users and directory - use the same ports for both virtual hosts (21) Is that possible? Best regards sangul
sangul (15 rep)
Dec 15, 2021, 07:45 AM • Last activity: Feb 20, 2022, 04:55 PM
3 votes
1 answers
1116 views
Setting up domain with multiple servers
I am setting up a small web hosting service for my clients. I have my dedicated server which will be the shared server to host clients websites using WHM/cPanel. I have a separate VPS server that I want to use for hosting my own sites, so that in the event the shared server goes down my clients can...
I am setting up a small web hosting service for my clients. I have my dedicated server which will be the shared server to host clients websites using WHM/cPanel. I have a separate VPS server that I want to use for hosting my own sites, so that in the event the shared server goes down my clients can still reach me to open tickets, etc. I have set up my business domain name on my shared server.  I created glue records within [Namecheap](https://en.wikipedia.org/wiki/Namecheap "domain name registrar") to set up ns1/ns2 so that my shared server can be reached using mydomain.com and can forward domains using ns1.mydomain.com and ns2.mydomain.com. What I want to do now is forward www.mydomain.com and mydomain.com to my VPS so that I can use it to host my main website. I have edited the DNS zone within WHM/cPanel to point the @ and www 'A Record' to my VPS IP address. Now when I try to visit www./mydomain.com it shows the Apache 2 test page as if vhosts weren't working. I have set up VPS before and never had this issue so I'm thinking either a problem with the DNS A/www records or I have missed something when configuring the VPS. Here is my vhosts within httpd.conf: (CentOS 6.5)
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
...

    ServerAdmin my@email.com
    DocumentRoot /var/www/html
    ServerName vps.mydomain.com
    ServerAlias 91.227.220.159



    ServerAdmin my@email.com
    DocumentRoot /var/www/username/public_html
    ServerName www.mydomain.com
    ServerAlias mydomain.com
If this was working then vps.mydomain.com and server IP should show the default apache page and mydomain.com should show the site located at /var/www/username/public_html. I appreciate this could be a hard question to answer but I am pulling my hair out.  Is there anything blatant obvious I could have missed? Is the way I'm setting up the domain the best route to take? The idea is that if my clients visit me at mydomain.com they'll be taken to my website on the VPA, but they can also use ns1.mydomain.com and ns2.mydomain.com to point domain to the shared server and hostname.mydomain.com for things like SSL when using IMAP, would there be a better way to achieve this? Maybe pushing domain back to Namecheap and managing DNS from there?
Goodbytes (141 rep)
Oct 26, 2014, 08:03 PM • Last activity: Oct 18, 2020, 11:04 PM
1 votes
1 answers
377 views
Setup vhost for subdomain
I am trying to make vhost, but it is kinda semi working. I am able to run the **index.php** and load home page, but when I try to go to any link I am getting: Not Found The requested URL /home was not found on this server. Apache/2.4.7 (Ubuntu) Server at c2s.dev Port 80 (I am using **yii2** framewor...
I am trying to make vhost, but it is kinda semi working. I am able to run the **index.php** and load home page, but when I try to go to any link I am getting: Not Found The requested URL /home was not found on this server. Apache/2.4.7 (Ubuntu) Server at c2s.dev Port 80 (I am using **yii2** framework, if that means something). I also can access the site using subdomain (I am getting Server not found). What is the proper configuration? I am using Linux Mint 17.1 with default **LAMP** settings. This is my c2s.conf: DocumentRoot /var/www/c2c/www ServerName c2s.dev ServerAlias *.c2s.dev And in /etc/hosts I added this: 127.0.1.1 c2s.dev 127.0.1.1 *.c2s.dev
Sasha (123 rep)
Mar 2, 2016, 12:50 PM • Last activity: Nov 25, 2018, 10:49 PM
0 votes
0 answers
385 views
Best practice for letting non-root user (ww-data) edit a NGINX vhost
I'm confronted with a scenario where I have to let users edit their vhost through a GUI written in PHP. The `www-data` user has already the necessary `sudo` entry to restart NGINX. Now I'm wondering what the best approach would be to let `www-data` write to a certain vhost. I think granting him writ...
I'm confronted with a scenario where I have to let users edit their vhost through a GUI written in PHP. The www-data user has already the necessary sudo entry to restart NGINX. Now I'm wondering what the best approach would be to let www-data write to a certain vhost. I think granting him write rights to /etc/nginx/sites-enabled would not be such a good idea. Should I else put the vhost in the home directory of www-data and link from /etc/nginx/sites-enabled/vhost to it? What would be the best/most secure way to grant www-data access to edit a certain NGINX vhost file?
manifestor (2563 rep)
May 4, 2018, 08:32 PM
1 votes
1 answers
133 views
Locate VHost files in CentOS
I was just given a server and need to configure some Vhosts files. They have no idea where are they anymore. How do I locate them?
I was just given a server and need to configure some Vhosts files. They have no idea where are they anymore. How do I locate them?
prgrm (115 rep)
Jul 4, 2017, 12:40 PM • Last activity: Jul 4, 2017, 01:23 PM
2 votes
4 answers
2461 views
Makefile alternative for those who don't want tab indenting all content under the opener
Is there a GNU `make` alternative if don't want to use tab indents in my `make` program (or `make`-like) program? For example, when I use `make`, I need to indent everything after the `make` opener, (`% :`). This is a recipe for some problems in some circumstances (for example, I work cross-platform...
Is there a GNU make alternative if don't want to use tab indents in my make program (or make-like) program? For example, when I use make, I need to indent everything after the make opener, (% :). This is a recipe for some problems in some circumstances (for example, I work cross-platform and I use a Windows10 AutoHotkey mechanism that strips tabs from codes I paste into Linux terminals from different reasons and it doesn't pass over make hence I need a non tab including solution). The necessity to tab-indent everything under % : makes my work with make non fluent. This is the make I use to create new virtual host conf files. I execute it with make domain.tld.conf: % : printf '%s\n' \ '' \ 'DocumentRoot "/var/www/html/$@"' \ 'ServerName $@' \ '' \ 'Options +SymLinksIfOwnerMatch' \ 'Require all granted' \ '' \ 'ServerAlias www.$@' \ '' \ > "$@" a2ensite "$@" systemctl restart apache2.service Is there any alternative, maybe something that comes with Unix itself that provides similar functionality but without having to use tab indents in the pattern file itself?
user149572
May 5, 2017, 04:51 AM • Last activity: May 16, 2017, 07:32 PM
2 votes
2 answers
676 views
generic massive vhost config causes 404 status code on every vhost request
I am trying to set up an apache 2.4 server with massive subdomains using ServerAlias. The basic configuration for the main domain works just fine (main domain => 200, all subdomains => 404): UseCanonicalName Off ServerName example.com ServerAlias www.example.com VirtualDocumentRoot "/var/www/vhosts/...
I am trying to set up an apache 2.4 server with massive subdomains using ServerAlias. The basic configuration for the main domain works just fine (main domain => 200, all subdomains => 404): UseCanonicalName Off ServerName example.com ServerAlias www.example.com VirtualDocumentRoot "/var/www/vhosts/example.com/httpdocs" DirectoryIndex index.php index.html Options +Indexes +FollowSymLinks +Includes Require all granted Order allow,deny Allow from all AllowOverride All But when I add the lines for my generic vhost set up the web server returns an 404 status code on every vhost (subdomain) request: UseCanonicalName Off ServerName example.com ServerAlias www.example.com VirtualDocumentRoot "/var/www/vhosts/example.com/httpdocs" DirectoryIndex index.php index.html ServerAlias *.example.com VirtualDocumentRoot "/var/www/vhosts/example.com/%1.0" DirectoryIndex index.php index.html Options +Indexes +FollowSymLinks +Includes Require all granted Order allow,deny Allow from all AllowOverride All I think it must have to do something with the right folder path. The folder path always looks like this: /var/www/vhosts/maindomain.com/subdomain.maindomain.com What I need is simply a configuration that matches the main domain and generic sub domains associated to that. So, www.example.com example.com matches folder path: /var/www/vhosts/example.com/httpdocs And ci.example.com tracker.example.com other.example.com should match to its folder path like this: /var/www/vhosts/example.com/ci.example.com /var/www/vhosts/example.com/tracker.example.com /var/www/vhosts/example.com/other.example.com Also, for some strange reason, if I change it to %0.0 in the subdomain path, the subdomains works, but the main domain does not. So, with using that, it's the other way around. Main domain => 404, all subdomains => 200. I found the explanation for the magic string literals for folder names in the apache 2.4 docs: http://httpd.apache.org/docs/2.4/mod/mod_vhost_alias.html But rather than solving my issue, it confuses me more and more... The web server runs under openSUSE 42.2 minimal. As you may already suggested, the real domain name is changed here to example.com. Any help to this issue would be great. Edit: As I said also down below in my comment to the first answer, I need a solution, that does not necessarily require any RewriteRule in the vhost config. Because I am using php systems, that do have their own (sometimes real complex) RewriteRules, so I do not want to get in trouble with that .htaccess stuff. But any other options, except cgi is possible. And yes, symlink support is enabled (or possible to enable it). ---- Edit: The symlink example helped me to get the basic idea. A bit rethinking brought me to this solution below. First found rule always applies, so it worked for me: UseCanonicalName Off DocumentRoot "/var/www/vhosts/example.com/httpdocs" ServerName www.example.com ServerAlias example.com Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted Allow from all DocumentRoot "/var/www/vhosts/example.com/httpdocs" ServerName example.com ServerAlias *.example.com VirtualDocumentRoot "/var/www/vhosts/example.com/%1" Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted Allow from all apachectl -t and apachectl -S says that this is ok. Tested and worked! :-)
alpham8 (61 rep)
Apr 17, 2017, 10:22 PM • Last activity: May 3, 2017, 07:29 AM
2 votes
3 answers
1967 views
Automating the Virtual host creation process
Until recently I used tools like Cpanel or Webmin to manage Apache2 virtual hosts. I recently discovered how to create these manually under `sites-available` directory. I can do this process manually time and again but when done manually it includes lot's of coping & pasting, repetitive string chang...
Until recently I used tools like Cpanel or Webmin to manage Apache2 virtual hosts. I recently discovered how to create these manually under sites-available directory. I can do this process manually time and again but when done manually it includes lot's of coping & pasting, repetitive string changes (once for the file name and of the domain+tld inside it, and further executions like a2ensite (see below). I now seek to automize the process but I'm not sure what is the best way to change domain+tld both inside (in the Vhost) and outside (in the file name and further executions) This is my way to manually create each Vhost: 1. Copy a ready Vhost template file (I have such a file which I name d.t and I clone it whenever I need to create a new Vhost): DocumentRoot "/var/www/html/d.t" ServerName www.d.t Options +SymLinksIfOwnerMatch Require all granted ServerAlias www.d.t 3. Search and replace "d.t", with domain+tld: Do in nano. 4. Replace filename (d.t) with domain+tld: mv /etc/apache2/sites-available/d.t /etc/apache2/sites-available/domain.tld 5. Enable domain.tld.conf & restart the Apache service: a2ensite domain.tld.conf && systemctl restart apache2.service This might seem simple but when I manually do this algorithm from a manual file it might take even more time to rewrite each example like d.t into the relevant domain+tld. My question: ------------ I am looking for a way to run a script with these actions: The script will actually look quite similar but in this script, d.t will be replaced with the script's very file name. For example, if the script's filename is MyNewVhost.com, each d.t occurrence inside it will become MyNewVhost.com. I guess some variable work can serve that purpose, but I might be wrong; If so, a way to tell the program "Put the file name in each d.t" seems to be what I need. Notes: ------ 1. I believe an answer could also give a good direction for people with a similar problem in Nginx Server blocks (Nginx Sblocks).
user149572
Mar 27, 2017, 10:29 PM • Last activity: Mar 30, 2017, 12:01 PM
2 votes
1 answers
523 views
Remove "ipv6only" option from Puppet nginx module
My nginx server (which serves multiple vhosts) fails to start: Nov 08 23:54:43 foo systemd[1]: Starting nginx - high performance web server... Nov 08 23:54:43 foo nginx[3830]: nginx: [emerg] duplicate listen options for [::]:8081 in /etc/nginx/sites-enabled/000-mysite.vhost:3 Nov 08 23:54:43 foo ngi...
My nginx server (which serves multiple vhosts) fails to start: Nov 08 23:54:43 foo systemd[1] : Starting nginx - high performance web server... Nov 08 23:54:43 foo nginx: nginx: [emerg] duplicate listen options for [::]:8081 in /etc/nginx/sites-enabled/000-mysite.vhost:3 Nov 08 23:54:43 foo nginx: nginx: configuration file /etc/nginx/nginx.conf test failed Nov 08 23:54:43 foo systemd[1] : nginx.service: control process exited, code=exited status=1 Nov 08 23:54:43 foo systemd[1] : Failed to start nginx - high performance web server. Nov 08 23:54:43 foo systemd[1] : Unit nginx.service entered failed state. Nov 08 23:54:43 foo systemd[1] : nginx.service failed. I've pinpointed the problem to two listen directives bound to the same TCP port for both IPv4 and IPv6, where the option ipv6only is used: [root@foo ~]# head /etc/nginx/sites-enabled/mysite.vhost server { listen 8081; listen [::]:8081 ipv6only=on; ssl off; ... So this configuration works correctly: [root@foo ~]# head /etc/nginx/sites-enabled/mysite.vhost server { listen 8081; listen [::]:8081; ssl off; ... [Related question: https://serverfault.com/questions/638367/do-you-need-separate-ipv4-and-ipv6-listen-directives-in-nginx] Now, this configuration is provisioned by Puppet via the puppet-nginx module . Is there a way to (via Puppet) not specify the ipv6only option, or solve the problem in another manner?
dr_ (32068 rep)
Nov 8, 2016, 01:56 PM • Last activity: Nov 10, 2016, 12:00 PM
4 votes
3 answers
9796 views
Apache not binding to port 80?
I am having issues with Apache. I just installed Centos and waant to create a webserver of my own. I am following the directions of "[the perfect server for centos 7.2](https://www.howtoforge.com/tutorial/perfect-server-centos-7-2-apache-mysql-php-pureftpd-postfix-dovecot-and-ispconfig/2/#-installin...
I am having issues with Apache. I just installed Centos and waant to create a webserver of my own. I am following the directions of "[the perfect server for centos 7.2](https://www.howtoforge.com/tutorial/perfect-server-centos-7-2-apache-mysql-php-pureftpd-postfix-dovecot-and-ispconfig/2/#-installing-apache-with-modphp-modfcgiphp-phpfpm) " and came upon this error on my machine [root@server01 /]# sudo systemctl start httpd Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details. [root@server01 /]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2016-11-02 14:04:03 PDT; 14s ago Docs: man:httpd(8) man:apachectl(8) Process: 30113 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE) Process: 30065 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) Main PID: 30065 (code=exited, status=1/FAILURE) Nov 02 14:04:01 server01.tcforwarding.com systemdReferenced image: Starting The Apache HTTP Server... Nov 02 14:04:02 server01.tcforwarding.com httpd: [Wed Nov 02 14:04:02.346089 2016] [alias:warn] [pid 30065] AH00671: The Scri...Alias. Nov 02 14:04:02 server01.tcforwarding.com httpd: AH00548: NameVirtualHost has no effect and will be removed in the next relea...nf:356 Nov 02 14:04:02 server01.tcforwarding.com httpd: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 Nov 02 14:04:02 server01.tcforwarding.com systemd: httpd.service: main process exited, code=exited, status=1/FAILURE Nov 02 14:04:02 server01.tcforwarding.com kill: kill: cannot find process "" Nov 02 14:04:03 server01.tcforwarding.com systemd httpd.service: control process exited, code=exited status=1 Nov 02 14:04:03 server01.tcforwarding.com systemd: Failed to start The Apache HTTP Server. Nov 02 14:04:03 server01.tcforwarding.com systemd: Unit httpd.service entered failed state. Nov 02 14:04:03 server01.tcforwarding.com systemd: httpd.service failed. This is a sample of my vhost file enter image description here Can someone please help me figure this out? running sudo netstat -nap | grep :80 returns [root@server01 /]# sudo netstat -nap | grep :80 tcp 0 0 192.168.0.22:56616 104.16.13.8:80 TIME_WAIT - tcp 0 0 192.168.0.22:43882 151.101.193.69:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:37556 151.101.129.69:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:37722 151.101.65.69:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:47506 151.101.1.69:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:55722 54.225.161.140:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:40710 107.14.33.34:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:43884 151.101.193.69:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:39374 50.16.185.14:80 ESTABLISHED 6833/firefox tcp 0 0 192.168.0.22:57408 104.16.12.8:80 ESTABLISHED 6833/firefox tcp6 0 0 2605:e000:9290:cf:57260 2607:f8b0:4007:80c::443 ESTABLISHED 6833/firefox tcp6 0 0 2605:e000:9290:cf:42280 2607:f8b0:4007:801:::80 ESTABLISHED 6833/firefox tcp6 0 0 2605:e000:9290:cf:35994 2607:f8b0:4007:80c::443 ESTABLISHED 6833/firefox tcp6 0 0 2605:e000:9290:cf:42210 2607:f8b0:4007:80b:::80 ESTABLISHED 6833/firefox now running the same command after shutting firefox down [root@server01 /]# sudo netstat -nap | grep :80 tcp 0 0 192.168.0.22:39514 151.101.129.69:80 TIME_WAIT - tcp 0 0 192.168.0.22:39516 151.101.129.69:80 TIME_WAIT - tcp 0 0 192.168.0.22:57042 54.243.224.230:80 TIME_WAIT - tcp 0 0 192.168.0.22:59396 104.16.12.8:80 TIME_WAIT - tcp 0 0 192.168.0.22:39734 151.101.65.69:80 TIME_WAIT - tcp 0 0 192.168.0.22:58596 104.16.13.8:80 TIME_WAIT - tcp 0 0 192.168.0.22:39510 151.101.129.69:80 TIME_WAIT - tcp 0 0 192.168.0.22:37124 96.6.122.178:80 TIME_WAIT - tcp 0 0 192.168.0.22:39696 151.101.65.69:80 TIME_WAIT - tcp 0 0 192.168.0.22:57710 54.225.161.140:80 TIME_WAIT - tcp 0 0 192.168.0.22:47790 64.95.32.61:80 TIME_WAIT - tcp6 0 0 2605:e000:9290:cf:33722 2607:f8b0:4007:80b::443 TIME_WAIT - tcp6 0 0 2605:e000:9290:cf:53536 2607:f8b0:4007:801::443 TIME_WAIT - tcp6 0 0 2605:e000:9290:cf:58196 2607:f8b0:4007:806:::80 TIME_WAIT - tcp6 0 0 2605:e000:9290:cf:51876 2607:f8b0:4007:800::443 TIME_WAIT - now running this command again systemctl status httpd.service I still encounter the same error [root@server01 /]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2016-11-02 20:34:28 PDT; 9s ago Docs: man:httpd(8) man:apachectl(8) Process: 17357 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE) Process: 17343 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) Main PID: 17343 (code=exited, status=1/FAILURE) Nov 02 20:34:27 server01.tcforwarding.com systemdReferenced image: Starting The Apache HTTP Server... Nov 02 20:34:28 server01.tcforwarding.com httpd: [Wed Nov 02 20:34:28.202720 2016] [alias:warn] [pid 17343] AH00671: The Scr...Alias. Nov 02 20:34:28 server01.tcforwarding.com httpd: AH00548: NameVirtualHost has no effect and will be removed in the next rele...nf:356 Nov 02 20:34:28 server01.tcforwarding.com httpd: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 Nov 02 20:34:28 server01.tcforwarding.com systemdReferenced image: httpd.service: main process exited, code=exited, status=1/FAILURE Nov 02 20:34:28 server01.tcforwarding.com kill: kill: cannot find process "" Nov 02 20:34:28 server01.tcforwarding.com systemdReferenced image: httpd.service: control process exited, code=exited status=1 Nov 02 20:34:28 server01.tcforwarding.com systemdReferenced image: Failed to start The Apache HTTP Server. Nov 02 20:34:28 server01.tcforwarding.com systemdReferenced image: Unit httpd.service entered failed state. Nov 02 20:34:28 server01.tcforwarding.com systemdReferenced image: httpd.service failed. Hint: Some lines were ellipsized, use -l to show in full. The problem is still stopping me from start up Running command nmap 192.168.0.1 returns Starting Nmap 6.40 ( http://nmap.org ) at 2016-11-06 15:52 PST Nmap scan report for server01.tcforwarding.com (192.168.0.1) Host is up (0.000016s latency). Not shown: 992 closed ports PORT STATE SERVICE 21/tcp open ftp 25/tcp open smtp 53/tcp open domain 110/tcp open pop3 143/tcp open imap 993/tcp open imaps 995/tcp open pop3s 3306/tcp open mysql Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds Why does port 80 or port 443 not show up at all?
Bryan Lopez (51 rep)
Nov 2, 2016, 09:31 PM • Last activity: Nov 7, 2016, 12:02 AM
1 votes
2 answers
885 views
Apache2 vHost Problem: subdomain isn't working right
First: I am pretty new to Linux/Apache My problem: I am trying to acces my forum via the subdomain forum.lumix-transporte.de. Usually you can acess it with lumix-transporte.de/forum. My forum.conf file: ServerName forum.lumix-transporte.de ServerAdmin admin@lumix-transporte.de DocumentRoot /var/www/...
First: I am pretty new to Linux/Apache My problem: I am trying to acces my forum via the subdomain forum.lumix-transporte.de. Usually you can acess it with lumix-transporte.de/forum. My forum.conf file: ServerName forum.lumix-transporte.de ServerAdmin admin@lumix-transporte.de DocumentRoot /var/www/forum Options Indexes FollowSymLinks MultiViews AllowOverride All When I am trying to access the forum with forum.lumix-transporte.de I am being redirected lumix-transporte.de so to the default Apache2 page "It works!". Also the Icon of the Software is shown in the Tab. default file in /etc/apache2/sites-available: ServerAdmin webmaster@localhost DocumentRoot /var/www Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined After executing the 2 commands that were suggested by jacek.ciach 3: root@lumix-transporte:/etc/apache2# grep -R Redirect * root@lumix-transporte:/etc/apache2# grep -R lumix-transporte.de * sites-available/default: ServerName lumix-transporte.de sites-available/forum.conf: ServerName forum.lumix-transporte.de sites-available/forum.conf: ServerAdmin admin@lumix-transporte.de sites-enabled/forum.conf: ServerName forum.lumix-transporte.de sites-enabled/forum.conf: ServerAdmin admin@lumix-transporte.de sites-enabled/000-default: ServerName lumix-transporte.de //After changing via phpmyadmin in the database wcf, the table wcf1_application and changing the domainpath from /forum to / and the domainname from lumix-transporte.de to forum.lumix-transporte.de it is finally working. Thank you jacek.ciach for saying that it may be caused by the forum itself. I found that after googling some more.
Splixz (15 rep)
Jun 14, 2015, 05:52 PM • Last activity: Aug 10, 2016, 01:01 PM
-2 votes
1 answers
97 views
CentOS, Apache Vhosts enabled,but DOCUMENT_ROOT cant towards /home/auser/website/www1
# environment # > CentOS 6.5 x86_64 > Apache2.4.9 *(locate=/usr/local/apache2)* > PHP 5.5.13 *(locate=/usr/local/php5)* > Apache vhosts enabled. site1 >>domain=localhost >>path=/usr/local/apache2/htdocs >>rst=OK site2 >>domain=phpmyadmin >>path=/usr/local/apache2/htdocs/phpmyadmin >>rst=OK site3 >>d...
# environment # > CentOS 6.5 x86_64
> Apache2.4.9 *(locate=/usr/local/apache2)*
> PHP 5.5.13 *(locate=/usr/local/php5)*
> Apache vhosts enabled.

site1 >>domain=localhost
>>path=/usr/local/apache2/htdocs
>>rst=OK
site2 >>domain=phpmyadmin
>>path=/usr/local/apache2/htdocs/phpmyadmin
>>rst=OK
site3 >>domain=phpmyadmin3
>>path=/home/default7/website/phpmyadmin
>>rst=You don't have permission to access /
site4 >>domain=mysite1
>>path=/home/default7/website/mysite1
>>result=You don't have permission to access /
When i turned off selinux,403 as the same.
Util (27 rep)
Jun 16, 2014, 01:40 PM • Last activity: Aug 10, 2016, 12:43 PM
1 votes
0 answers
264 views
502 Proxy Error - PUT request to MDM OSX Server via apache ProxyPass on ubuntu 14
I am trying to set up a OSX Server behind an ubuntu server with apache2 and vhosts which uses proxypass to send requests to my OSX server. Most request work like they should but I am unable to make the put request work, I get the following error. This is result is via curl but it says the same thing...
I am trying to set up a OSX Server behind an ubuntu server with apache2 and vhosts which uses proxypass to send requests to my OSX server. Most request work like they should but I am unable to make the put request work, I get the following error. This is result is via curl but it says the same thing. > The proxy server could not handle the request PUT > /devicemanagement/api/device/mdm_checkin This is the command I used > curl -k -X PUT > "https://mysupercoolserver.xyz/devicemanagement/api/device/mdm_checkin " -d > checkin-data.plist The following is my vhost configuration ServerName mysupercoolserver.xyz ProxyPass / http://10.0.1.40/ ProxyPassReverse / http://10.0.1.40/ ProxyPreserveHost on Require all granted ServerName mysupercoolserver.xyz SSLEngine On SSLProxyEngine On ProxyRequests Off SSLProxyCheckPeerCN off SSLProxyCheckPeerExpire off SSLProxyCheckPeerName off SSLInsecureRenegotiation on SSLProxyVerify none SSLVerifyClient none SSLCertificateFile /etc/ssl/mysupercoolserver_xyz.crt SSLCertificateKeyFile /etc/ssl/mysupercoolserver_xyz.key SSLCertificateChainFile /etc/ssl/mysupercoolserver_xyz.ca-bundle ProxyPass / https://10.0.1.40/ retry=1 acquire=3000 timeout=600 Keepalive=On ProxyPassReverse / https://10.0.1.40/ Timeout 2400 ProxyTimeout 2400 ProxyBadHeader Ignore ProxyPreserveHost on Require all granted ServerName mysupercoolserver.xyz ProxyPass / http://10.0.1.40:1640/ ProxyPassReverse / http://10.0.1.40:1640/ ProxyPreserveHost on Require all granted ServerName mysupercoolserver.xyz ProxyPass / http://10.0.1.40:2195/ ProxyPassReverse / http://10.0.1.40:2195/ ProxyPreserveHost on Require all granted **Is there anything I can change here to solve the issue?** https:// works for downloading the profile and certificate and I know the other ports work as well since requests are going through.
Matkey (11 rep)
Jun 15, 2016, 01:15 PM
3 votes
1 answers
26339 views
Apache "RSA server certificate CN does not match server name" error
I have an apache installation with some name-based vhosts and a SSL certficate with CN=`maindomain.com` and DNS Alternative Names for the all the vhosts (sub)domains. However, this setup gives warnings in the logs in the form: [Fri Jan 03 16:52:38 2014] [warn] RSA server certificate CommonName (CN)...
I have an apache installation with some name-based vhosts and a SSL certficate with CN=maindomain.com and DNS Alternative Names for the all the vhosts (sub)domains. However, this setup gives warnings in the logs in the form: [Fri Jan 03 16:52:38 2014] [warn] RSA server certificate CommonName (CN) `maindomain.com' does NOT match server name!? [Fri Jan 03 16:52:38 2014] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) While working, I should say that Name-based SSL vhosts are irrelevant because the certificate is for all vhosts. Furthermore I would say the CN matches the main ServerName. Is there any way to fix this and clear the logs? Distilled configuration is as follows: Servername maindomain.com ServerName www.maindomain.com DocumentRoot /var/www/www.maindomain.com/public_html/ ServerName www.maindomain.com Include ssl.vhost.conf DocumentRoot /var/www/www.maindomain.com/public_html/ ServerName altdomain.com DocumentRoot /var/www/altdomain.com/public_html/ ServerName altdomain.com Include ssl.vhost.conf DocumentRoot /var/www/altdomain.com/public_html/ # More vhosts in the same way, sometimes tld's sometimes subdomains And ssl.vhost.conf as follows: SSLEngine ON SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM SSLCertificateFile /etc/certificates/maindomain.com.crt SSLCertificateKeyFile /etc/certificates/maindomain.com.key SSLCertificateChainFile /etc/certificates/ca-intermediate.crt SSLCACertificateFile /etc/certificates/ca.crt
dtech (987 rep)
Jan 5, 2014, 12:09 PM • Last activity: Jun 5, 2016, 07:00 PM
0 votes
1 answers
295 views
Solid State drive vs. traditional hard disk in a virtual server environment
I am currently considering upgrading my virtual-hosting plan because of very bad write performance (mostly writing to a MySQL database, but I notice it also when compiling a program or copying files - or any other write operation). At some times (probably when many other customers on other vhosts ar...
I am currently considering upgrading my virtual-hosting plan because of very bad write performance (mostly writing to a MySQL database, but I notice it also when compiling a program or copying files - or any other write operation). At some times (probably when many other customers on other vhosts are using the hard-drive) a write can take up to several dozens(!) of seconds, even when it's a small write operation, which is unacceptable. Read performance is much better, probably because of good caching (in fact when we start using the database at the morning each day, we notice how slow it is at first which would suggest that the cache is being filled - but that is OK with us). I don't know the specifics of how the hard-drive is used and prioritized in a Linux/vhost environment, but I can imagine that a lot of time is lost by jumping between vhost-partitions. On the other hand, it may also be possible that an SSD pretty much behaves like an HDD (only a bit faster, which would not be enough for me - 20 instead of 30 seconds is still unacceptable) from the user's point of view. Does anybody have experience with both HDDs and SSDs in an vhost-environment? Is there a different "character" (regarding relative speeds of reads and writes and especially latency) noticeable as a user? How is the hard-drive prioritized and in which ways does an SSD make a difference, especially on a overloaded vhost-system? Do you think that changing to an SSD can prevent this extremely bad write-performance spikes?
Robby75 (101 rep)
Jul 29, 2014, 09:50 AM • Last activity: Jul 29, 2014, 11:48 AM
Showing page 1 of 20 total questions