Configure Apache web server to perform SSL authentication - linux

I'm trying to perform SSL authentication in apache web server, using XAMPP in Linux. After I configure httpd.conf like this, Apache server is failing to start. Can some one help me to fix this ? What is wrong with my configuration ?
Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"
<Directory "/opt/lampp/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Listen 443
<VirtualHost 127.0.0.1:443>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost.localdomain
SSLEngine on
SSLCertificateFile "/home/lahiru/Desktop/ucsc/security/ssl/server.cer"
SSLCertificateKeyFile "/home/lahiru/Desktop/ucsc/security/ssl/server.key"
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile "/home/lahiru/Desktop/ucsc/security/ssl/ca.cer"
</VirtualHost>
And the Apache error log says,
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
[Sun Jun 21 07:42:47.000754 2015] [ssl:warn] [pid 1863] AH01909: localhost.localdomain:443:0 server certificate does NOT include an ID which matches the server name
[Sun Jun 21 07:42:47.001082 2015] [ssl:warn] [pid 1863] AH01906: www.example.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Jun 21 07:42:47.001101 2015] [ssl:warn] [pid 1863] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Jun 21 07:42:47.001183 2015] [suexec:notice] [pid 1863] AH01232: suEXEC mechanism enabled (wrapper: /opt/lampp/bin/suexec)

Bitnami developer here,
In XAMPP the SSL configuration is located at /opt/lampp/etc/extras/httpd-ssl.conf file, where there is a default VirtualHost already configured in port 443, and you are trying to bind again the same port.
Please, try to modify this file instead. You can check if there is any other process using port 443 running command sudo netstat -vnpa | grep 443
What do you mean with "Apache server is failing to start"? Using the /opt/lampp/ctlscript.sh script to restart Apache server didn't produce any error message on my side but the error_log told me the same that you mentioned.
Regards,
Gonzalo

Related

Intermittent Service not available Error in Elasticbeanstalk application

We are using a webserver with ElasticBeanstalk from 2019.,
the platform is
tomcat 8.5 with java8 running on 64 bit Amazon Linux. httpd as proxy
recently (from Jan 30th) we started getting Service Unavailable issues if go to the endpoint from time to time. and if we refresh 2-3 times it will get resolved on its own.
then I download full logs. under elasticbeanstalk-error_log I can see
[Mon Feb 28 10:00:58.338035 2022] [proxy:error] [pid 14882:tid 139757313533696] (13)Permission denied: AH02454: HTTP: attempt to connect to Unix domain socket /var/run/httpd/ (localhost) failed
[Mon Feb 28 10:00:58.338078 2022] [proxy_http:error] [pid 14882:tid 139757313533696] [client <private-ip-here>:12566] AH01114: HTTP: failed to make connection to backend: httpd-UDS, referer: http://<custom-end-point>/1/<name.jsp>?s=sec$$4P!&refresh=300
[Mon Feb 28 10:43:40.663468 2022] [proxy:error] [pid 14882:tid 139757120071424] (13)Permission denied: AH02454: HTTP: attempt to connect to Unix domain socket /var/run/httpd/ (localhost) failed
[Mon Feb 28 10:43:40.663518 2022] [proxy_http:error] [pid 14882:tid 139757120071424] [client <private-ip-here>:21136] AH01114: HTTP: failed to make connection to backend: httpd-UDS
repeated multiple times from Jan30th.
and when I look at access.log
I can see 503 error log exactly at the same time when permission denied error logs in elasticbeanstalk-error_log
And I looked at the running process using ps -aux | grep HTTPd and ps -aux | grep tomcat
both are running from 2019 and have no restarts.
what more I can do to troubleshoot these issuesWe are running a web application written in Java(tomcat8) hosted in AWS ElastcBeanStalk
Some weeks back we started getting 503 error randomly
When we checked the elasticbeanstalk-erorr_logs
[Thu Mar 03 13:22:12.906144 2022] [proxy:error] [pid 14882:tid 139757338711808] (13)Permission denied: AH02454: HTTP: attempt to connect to Unix domain socket /var/run/httpd/ (localhost) failed
[Thu Mar 03 13:22:12.906202 2022] [proxy_http:error] [pid 14882:tid 139757338711808] [client 172.31.17.0:61382] AH01114: HTTP: failed to make connection to backend: httpd-UDS, referer: http://our-domain.com/1/callBackLog.jsp
The error logs are suggesting connection error with backend unix socket
When we checked in /var/run/httpd/ folder, there were no unix sockets(.sock files)
But in apache httpd config
<VirtualHost *:80>
<Proxy *>
Require all granted
ProxyPass / http://localhost:8080/ retry=0
ProxyPassReverse / http://localhost:8080/
ProxyPreserveHost on
ErrorLog /var/log/httpd/elasticbeanstalk-error_log
the proxy backend is ip address not unix socket
As per the config httpd should connect to backend ip address(localhost:8080) but why is it complaining about unix socket
Have anyone faced similar issues?
============= UPDATE
The error logs are suggesting connection error with backend unix socket
When we checked in /var/run/httpd/ folder, there were no unix sockets(.sock files)
But in apache httpd config
<VirtualHost *:80>
<Proxy *>
Require all granted
ProxyPass / http://localhost:8080/ retry=0
ProxyPassReverse / http://localhost:8080/
ProxyPreserveHost on
ErrorLog /var/log/httpd/elasticbeanstalk-error_log
the proxy backend is ip address not unix socket
As per the config httpd should connect to backend ip address(localhost:8080) but why is it complaining about unix socket
Have anyone faced similar issues?

.Net Core 3.1 deploy on Centos 7

I am trying to run my .net Core web api application on Centos 7 + Plesk server. My application will be running in the subdomain. I set up a subdomain from the Plesk panel and transferred my files. After, I followed the article below step by step, it is not a very explanatory or helpful article.
https://learn.microsoft.com/tr-tr/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
First of all, this path does not exist /etc/nginx/sites-available/default. So with the help of other articles, I created the file api.mysite.com.conf in the etc/nginx/conf.d folder.
To configure Nginx as a reverse proxy to forward HTTP requests to your
ASP.NET Core app, modify /etc/nginx/sites-available/default. Open it
in a text editor, and replace the contents with the following snippet.
server {
listen 80;
server_name api.mysite.com *.mysite.com;
location / {
.... same as in docs.
}
}
Secondly, I created the service file by following the document. "/usr/bin/dotnet" This directory does not exist at this step, the document is not surprising again.
I solved this step by typing "/usr/share/dotnet/dotnet" instead of "/usr/bin/dotnet".
sudo nano /etc/systemd/system/kestrel-webapi.service
[Unit]
Description=Example .NET Web API App running on Centos 7
[Service]
WorkingDirectory=/var/www/vhosts/mysite.com/api.mysite.com
ExecStart=/usr/share/dotnet/dotnet /var/www/vhosts/mysite.com/api.mysite.com
After creating the service, I ran it without any problems.
The next step was Apache configuration.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
Configuration files for Apache are located within the
/etc/httpd/conf.d/ directory. Any file with the .conf extension is
processed in alphabetical order in addition to the module
configuration files in /etc/httpd/conf.modules.d/, which contains any
configuration files necessary to load modules.
I'm creating a configuration file in the "/etc/httpd/conf.d" file.
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr=${REQUEST_SCHEME}
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName www.mysite.com
ServerAlias *.mysite.com
ErrorLog ${APACHE_LOG_DIR}webapi-error.log
CustomLog ${APACHE_LOG_DIR}webapi-access.log common
</VirtualHost>
After making this configuration, I got an error while running the following commands in order.
sudo service httpd configtest
sudo systemctl restart httpd
[Fri May 28 19:35:02.344213 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${REQUEST_SCHEME} is not defined
[Fri May 28 19:35:02.344814 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Fri May 28 19:35:02.344853 2021] [core:warn] [pid 25339:tid 139880432744576] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
Syntax OK
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897163 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${REQUEST_SCHEME} is not defined
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897775 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
May 28 19:39:16 localhost.localdomain httpd[25740]: [Fri May 28 19:39:16.897825 2021] [core:warn] [pid 25740:tid 140630647605376] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
May 28 19:39:16 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 28 19:39:16 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
May 28 19:39:16 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
May 28 19:39:16 localhost.localdomain systemd[1]: httpd.service failed.
Before doing these operations, when I opened api.mysite.com through the browser, the plesk panel welcome page was displayed. I solved this problem by writing the following code, now I am getting 403 forbidden error.
mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_backup
How do I solve the above two problems? How can I redirect to my web api application when I connect to api.mysite.com?
I've been struggling with this for 3 days and I can't find the right articles on the internet, is there anyone who can help me?
I solved the problem.
When we create a domain in the plesk panel, apache creates its own configuration file, so all I have to do is change the Additional apache directives settings from within Apache & nginx under the Hosting & DNS settings of the relevant domain from the plesk panel.
Plesk --> Websites & Domains --> <> --> Hosting & DNS --> Apache & nginx
Additional directives for HTTP
Header set Access-Control-Allow-Origin "http://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
Additional directives for HTTPS
Header set Access-Control-Allow-Origin "https://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
If you have a cors problem, you can add lines starting with header set.
After doing all these, your application will run if it is ready in your service file.

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

Migrate web application from xmapp to lamp

I have developed web application using codeigniter on xampp server.
and want to deploy it on LAMP server. I have migrated database and app successfully but facing some problem.
When request web page using browser its not show anything not even error.
I have enabled selinux,
have root account and testing using root account
virtual host file config in /etc/httpd/conf.modules.d/hotelking.conf
<VirtualHost *:80>
ServerName www.hotelking.com
ServerAlias hotelking.com
DocumentRoot /var/www/hotelking/app/
Customlog "logs/www.hotelking.com.log" combined
ErrorLog "log/www.hotelking.com.error_log"
<Directory /var/www/hotelking/app/>
Require all granted
</Directory>
And error log have following error
[Wed Jan 06 03:20:14.515526 2016] [:error] [pid 6912] [client 127.0.0.1:40964] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
[Wed Jan 06 03:20:21.773841 2016] [:error] [pid 6908] [client 127.0.0.1:40965] PHP Fatal error: Class 'MY_controller' not found in /var/www/hotelking/app/application/controllers/master.php on line 5
I CHECKED IT HAS MY_controller at give location

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..................

Resources