Debian 9 Apache : Missing address for VirtualHost - linux

i keep getting this error after running the command
# sudo apache2ctl configtest
[Wed Mar 18 15:19:09.134018 2020] [core:error] [pid 10656:tid 140336746033216] (EAI 2)Name or service not known: AH00547: Could not resolve host name www.toutic.com: -- ignoring!
AH00526: Syntax error on line 1 of /etc/apache2/sites-enabled/toutic.com.conf:
Missing address for VirtualHost
Action 'configtest' failed.
The Apache error log may have more information.
here is the /etc/apache2/sites-enabled/toutic.com.conf file :
<VirtualHost *: 80>
ServerAdmin admin#toutic.com
ServerName toutic.com
ServerAlias www.toutic.com
DocumentRoot /var/www/toutic.com/public_html
ErrorLog ${APACHE_LOG_DIR
}/error.log
CustomLog ${APACHE_LOG_DIR
}/access.log combined
</VirtualHost>
here are the steps i followed : https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-debian-9

Remove everything and try like this:
<VirtualHost *:80>
ServerName toutic.com
ServerAlias www.toutic.com
DocumentRoot /var/www/toutic.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Related

One of subdomain VirtualHost cannot access on apache2

Company purchased a new server device,
currently we need to migrate the old project to the new one,
while we adding virtual host into new apache,
one of the site cannot access, this just happen today.
the following site cannot access,
coltd.domain.mo
I am trying find out why and fix it.
Following status which checked earlier.
The 000-default.conf file:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t>
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.mo
DocumentRoot /var/www
</VirtualHost>
...
...
<VirtualHost *:80>
ServerName merch.domain.mo
DocumentRoot /var/www/merch
</VirtualHost>
<VirtualHost *:80>
ServerName coltd.domain.mo
DocumentRoot /var/www/co_ltd
</VirtualHost>
some checking method from google
apache2 -v
---
Server version: Apache/2.4.48 (Ubuntu)
Server built: 2022-06-14T12:33:28
apache2ctl -S
---
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 merch.domain.mo (/etc/apache2/sites-enabled/000-default.conf:70)
...
# All other sites working fine
# Only coltd.domain.mo cannot access
...
port 80 namevhost coltd.domain.mo (/etc/apache2/sites-enabled/000-default.conf:74)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
sudo systemctl status apache2
[sudo] password for webserver:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-01-27 13:11:51 HKT; 36min ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 1095322 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 1095326 (apache2)
Tasks: 11 (limit: 11862)
Memory: 19.1M
CPU: 367ms
CGroup: /system.slice/apache2.service
├─1095326 /usr/sbin/apache2 -k start
├─1095327 /usr/sbin/apache2 -k start
├─1095328 /usr/sbin/apache2 -k start
├─1095329 /usr/sbin/apache2 -k start
├─1095330 /usr/sbin/apache2 -k start
├─1095331 /usr/sbin/apache2 -k start
├─1095400 /usr/sbin/apache2 -k start
├─1095406 /usr/sbin/apache2 -k start
├─1095407 /usr/sbin/apache2 -k start
├─1095408 /usr/sbin/apache2 -k start
└─1095409 /usr/sbin/apache2 -k start
Jan 27 13:11:50 webserver-27 systemd[1]: Starting The Apache HTTP Server...
Jan 27 13:11:51 webserver-27 systemd[1]: Started The Apache HTTP Server.
The *.domain.mo/coltd/ can be access, but not coltd.domain.mo,
Tried create new coltd.domain.mo.conf and test a2dissite 000-default.conf is working,
(assume nothing wrong with apache2)
Checked sudo apache2ctl configtest result syntax OK,
restarted sudo systemctl reload apache2 and restart apache2,
Hopefully found the reason,
we know should be separate all subdomain files, but we plan to do that on next step.
sadly currently small project still adding in 000-default.conf.
Thanks all kinds help.

Apache reverse-proxy to NodeJS WebSocket Server

Before all, yes I have checked other posts like this, this or even this among others.
This being said, let me expose my case:
It works on the dev-env (localhost) completely fine (of course, it doesn't require any proxy)
I also use this curl command to confirm:
curl 'http://localhost:9021/ws' \
--http1.1 \
-H 'Pragma: no-cache' \
-H 'Sec-WebSocket-Key: W/ZEACBv+gi6xA1JeMaO/A==' \
-H 'Upgrade: websocket' \
-H 'Cache-Control: no-cache' \
-H 'Connection: Upgrade' \
-H 'Sec-WebSocket-Version: 13'
and it connects ok.
When I run it on the remote dev server, I have this Apache config:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName dev.remote.com
LogLevel warn
ErrorLog "| /usr/bin/rotatelogs -l /home/user/log/dev.remote.com/error.%Y-%m-%d 86400"
CustomLog "| /usr/bin/rotatelogs -l /home/user/log/dev.remote.com/access.%Y-%m-%d 86400" combined
ServerSignature Off
DocumentRoot /home/user/www/dev.remote.com
<Directory /home/user/www/dev.remote.com>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<Location />
Options FollowSymLinks
</Location>
#
# Serve static files directly with Apache
#
ProxyPass /public !
Alias /public /home/user/www/dev.remote.com/public
<Directory /home/user/www/dev.remote.com/public>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ProxyPass /assets !
Alias /assets /home/user/www/dev.remote.com/.next/static/assets
<Directory /home/user/www/dev.remote.com/.next/static/assets>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
#
# Serve the rest with NodeJS/express
#
RewriteEngine On
LogLevel alert rewrite:trace6
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule /ws ws://localhost:9021/ws [P]
ProxyPreserveHost On
ProxyRequests off
# WebSocket server (express) is on port 9021
ProxyPass /ws ws://localhost:9021/ws
ProxyPassReverse /ws ws://localhost:9021/ws
# HTTP server (express) is on port 9020
ProxyPass / http://localhost:9020/
ProxyPassReverse / http://localhost:9020/
<Proxy *>
Require all granted
</Proxy>
SSLCertificateFile /etc/letsencrypt/live/dev.remote.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dev.remote.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
So 2 points here:
1.
I'm sure the WebSocket server is working on the remote server by testing via ssh with the previous curl command. And it connects.
2.
When I try opening the connection from the browser
ws = new WebSocket('wss://dev.remote.com/ws');
the mod_rewrite rule seems ok because the trace is like this:
[Fri May 28 17:37:16.272448 2021] [rewrite:trace2] [pid 15772] mod_rewrite.c(477): [client a.b.c.d:63015] a.b.c.d - - [dev.remote.com/sid#6916462d1a20][rid#69164d3530a0/initial] init rewrite engine with requested uri /ws
[Fri May 28 17:37:16.272475 2021] [rewrite:trace3] [pid 15772] mod_rewrite.c(477): [client a.b.c.d:63015] a.b.c.d - - [dev.remote.com/sid#6916462d1a20][rid#69164d3530a0/initial] applying pattern '/ws' to uri '/ws'
[Fri May 28 17:37:16.272505 2021] [rewrite:trace4] [pid 15772] mod_rewrite.c(477): [client a.b.c.d:63015] a.b.c.d - - [dev.remote.com/sid#6916462d1a20][rid#69164d3530a0/initial] RewriteCond: input='Upgrade' pattern='upgrade' [NC] => matched
[Fri May 28 17:37:16.272513 2021] [rewrite:trace2] [pid 15772] mod_rewrite.c(477): [client a.b.c.d:63015] a.b.c.d - - [dev.remote.com/sid#6916462d1a20][rid#69164d3530a0/initial] rewrite '/ws' -> 'ws://localhost:9021/ws'
[Fri May 28 17:37:16.272521 2021] [rewrite:trace2] [pid 15772] mod_rewrite.c(477): [client a.b.c.d:63015] a.b.c.d - - [dev.remote.com/sid#6916462d1a20][rid#69164d3530a0/initial] forcing proxy-throughput with ws://localhost:9021/ws
[Fri May 28 17:37:16.272529 2021] [rewrite:trace1] [pid 15772] mod_rewrite.c(477): [client a.b.c.d:63015] a.b.c.d - - [dev.remote.com/sid#6916462d1a20][rid#69164d3530a0/initial] go-ahead with proxy request proxy:ws://localhost:9021/ws [OK]
So I deduct the rules are working and it's actually making the request via proxy to :ws://localhost:9021/ws
But... there's no connection received in the WebSocket server.
Therefore, I get this on Chrome:
WebSocket connection to 'wss://dev.remote.com/ws' failed
The key was to have proxy_wstunnel mod active >_<
In case it helps anyone...
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/proxy_wstunnel.load
stupid error, but I was too focused on the configuration, and it was about enabled mods

redirect Apache Server document root to SpringBoot app

I have modified the file:
/etc/apache2/sites-available/elcor.com.conf
adding:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster#elcor.com
ServerName elcor.com
ServerAlias www.elcor.com
ProxyPass / http://localhost:8080/home.html
ProxyPassReverse / http://localhost:8080/html
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/elcor.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/elcor.com/log/error.log
CustomLog /var/www/html/elcor.com/log/access.log combined
</VirtualHost>
in order to access a SpringBoot app I have in the same server, but when I acees the site, this is what I see:
When I start Apache I have this error:
-- The job identifier is 483.
Dec 01 14:16:08 localhost apachectl[1099]: AH00526: Syntax error on line 9 of /etc/apache2/sites-enabled/elcor.com.conf:
Dec 01 14:16:08 localhost apachectl[1099]: Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configuration
Dec 01 14:16:08 localhost apachectl[1086]: Action 'start' failed.
Dec 01 14:16:08 localhost apachectl[1086]: The Apache error log may have more information.
Dec 01 14:16:08 localhost systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
could it be the case you did not enable mod_proxy on your system?
you can do that via "a2enmod proxy_http" on your ubuntu system

Apache mod_wl2.4 plugin error parseJVMID

I have some issues with setting an clustered environment for weblogic and Apache. The structure is like this: 1 webserver that proxies requests to a clustered environment of 3 weblogic servers.
Everytime i send the request to the apache server , the request gets unhandled. I figured out a part of the problem , but that is something that is not intended in production. whenever i add DynamicServerList On the requests fail. When i switch it to off it works, but that means whenever a server fails , apache will still send requests to that server and user experience would be 0.
EDIT 1: I am using weblogic 12c and apache2.4 for Centos 7
EDIT 2: There is no firewall nor selinux active
Here is my config file for weblogic plugin:
<VirtualHost *:8080>
ServerAdmin postmaster#webserver2
ServerName webserver2
DocumentRoot /var/www/webserver2/htdocs
ErrorLog /var/log/httpd//webserver-error_log
CustomLog /var/log/httpd/webserver-access_log forwarded
<Directory />
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html
<Location />
SetHandler weblogic-handler
</Location>
<IfModule mod_weblogic.c>
WeblogicCluster 192.168.166.70:8001,192.168.166.71:8001,192.168.166.69:8001
ConnectTimeoutSecs 15
ConnectRetrySecs 10
WLIOTimeoutSecs 600
DynamicServerList ON
Idempotent ON
FileCaching ON
KeepAliveSecs 60
KeepAliveEnabled ON
DebugConfigInfo ON
</IfModule>
</VirtualHost>
And the errors I get are the following:
[Mon Sep 14 09:54:58.480616 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
parseJVMID: could not resolve hostname '-1062689209'. Returning NULL
from parseJVMID
[Mon Sep 14 09:54:58.480681 2015] [weblogic:error]
[pid 15343:tid 140547949991680] [client 172.18.132.50:57991]
<1534314422136982> initJVMID: parseClusterServerList failure
[Mon Sep
14 09:55:28.481215 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
request [/clusterjsp/HaJsp.jsp] did NOT process
successfully..................

Apache2 in Ubuntu - configuration domain - page not found

I have a project in Zend, in directory: /var/www/Project/public
A content of file httpd.conf is:
<VirtualHost 127.0.0.1:80>
DocumentRoot "/var/www/Project/public"
ServerName project.localhost
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/var/www/Project/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and /etc/hosts:
127.0.0.1 localhost
127.0.1.1 michal-centrala
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 project.localhost
When I go to page http://project.localhost i get the following error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
The server log is following:
[Sun Jun 23 01:31:56 2013] [alert] [client 127.0.0.1] /var/www/Project/public/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Where's the problem?
Enable mod_rewrite in httpd.conf
Most likely line
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
is commented out
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so

Resources