Apache2 proxy showing 2 slots and PIDs? - apache

I'm running one single tomcat webserver behind an apache2 proxy. But
localhost:443/status shows:
Slot PID Stopping Connections Threads Async connections
total accepting busy idle writing keep-al closing
0 1578 no 0 yes 0 25 0 0 0
1 1577 no 1 yes 1 24 0 1 0
Sum 2 0 1 1 49 0 1 0
I wonder why I might have 2 PIDs running? Especially what I don't like is that apache has 50 workers, but reserves 25 worker threads for each of the PID. Ideally I'd want to to have all 50 workers reserved for the tomcat server.
Could this be due to my setup of 2 virtual hosts in /etc/apache2/sites-enabled/mypage.conf:
<VirtualHost *:443>
..
</VirtualHost>
<VirtualHost *:80>
Redirect / https:myserver.com/
</VirtualHost>
I'm just having this to redirect any non-https requests. Could this trigger those 2 PIDs? If yes: most likely only a few requests will come on port 80, so I would want to assign most of the workers to the https host. Is that possible?
What I also noticed: ps aux | grep apache2 gives 5 processes:
www-data 1577 0.0 0.1 2090340 14644 ? Sl 06:25 0:04 /usr/sbin/apache2 -k start
www-data 1578 0.0 0.1 2024812 12948 ? Sl 06:25 0:05 /usr/sbin/apache2 -k start
root 1679 0.0 0.1 92580 8196 ? Ss Jan08 0:44 /usr/sbin/apache2 -k start
www-data 1757 0.0 0.0 19904 172 ? Ss Jan08 0:29 /usr/bin/htcacheclean -d 120 -p /var/cache/apache2/mod_cache_disk -l 300M -n
mysshusr 19322 0.0 0.0 14856 1100 pts/0 S+ 10:53 0:00 grep --color=auto apache2
Are those the worker threads?

Related

stopped httpd but localhost still bind to 0.0.0.0:80

I use brew to install httpd, I stopped the service using brew services stop httpd then I visit locahost, I still can see apache is running?
You need to give following command: service httpd stop
You must kill the processes. As I can see from your comment you are running httpd as the users www and root:
_www 3356 0.0 0.0 2455088 704 ?? S 9:25AM 0:00.00 /usr/sbin/httpd -D FOREGROUND
root 3355 0.0 0.0 2455344 3588 ?? Ss 9:25AM 0:00.14 /usr/sbin/httpd -D FOREGROUND
private.laptop 3967 0.0 0.0 2444068 816 s004 S+ 9:46AM 0:00.00 grep httpd
The first column represent the user and the second column the process ID or PID.
Try running:
sudo kill -9 3356
sudo kill -9 3355
After each execution verify the services dissapear using ps aux | grep httpd
The last proccess private.laptop isn't related to your problem so no need to kill it.
If your problem isn't solved by this, maybe a daemon is executing your httpd, please refeer to this.

ssh keeps spawning swarm of processes even after killing them

Our EC2 instance has been experiencing very slow connection lately.
After we investigate deeper, we found out that there are few hundred ssh processes running, and they are all trying to connect to the same host (i.e it's almost like ddos attack against that host).
ps aux | grep ssh
root 971 0.0 0.0 61364 3084 ? Ss Dec11 0:00 /usr/sbin/sshd -D
root 7649 0.0 0.0 105628 4228 ? Ss 03:57 0:00 sshd: ubuntu [priv]
ubuntu 7811 0.0 0.0 106404 2740 ? S 03:57 0:00 sshd: ubuntu#pts/0
ubuntu 8616 0.0 0.0 44012 2516 pts/2 S 04:02 0:00 ssh deploy#xxx.xxx.xxx.xxx
ubuntu 8618 0.0 0.0 44012 2512 pts/2 S 04:02 0:00 ssh deploy#xxx.xxx.xxx.xxx
ubuntu 8620 0.0 0.0 44012 2512 pts/2 S 04:02 0:00 ssh deploy#xxx.xxx.xxx.xxx
ubuntu 8622 0.0 0.0 44012 2512 pts/2 S 04:02 0:00 ssh deploy#xxx.xxx.xxx.xxx
ubuntu 8624 0.0 0.0 44012 2516 pts/2 S 04:02 0:00 ssh deploy#xxx.xxx.xxx.xxx
...
Here I logged in as ubuntu. I vaguely remember I executed the command a while ago trying to connect to the host, but ssh outputs many instances of itself and the terminal got frozen, and since then we have been experiencing the slow connection issue.
Anyhow, I tried to kill all of the ssh processes, but they just keep coming back and eventually slow down the whole system connection again.
$ killall -9 ssh
Any idea what went wrong and how can I solve this problem?

Can't upload files in redmine (using centos 7)

I installed redmine 2.6.6.stable in a centos 7 vm (kernel 3.10.0-229.7.2.el7.x86_64). So far it's fine, but I'm currently unable to upload files.
Googling around I found out that the Passenger writes these files (https://www.redmine.org/issues/8817), and it's probably without the correct write permissions.
But I tried to fix it for the last 2 hours, with no success.
Apache's error_log when I try to upload something:
App 3419 stderr: Errno::EACCES (Permission denied - /var/www/html/vhosts/redmine/files/2015/08/150811151550_icon.png):
App 3419 stderr: app/models/attachment.rb:108:in `initialize'
App 3419 stderr: app/models/attachment.rb:108:in `open'
App 3419 stderr: app/models/attachment.rb:108:in `files_to_final_location'
App 3419 stderr: app/controllers/attachments_controller.rb:88:in `upload'
These are the current permissions for my redmine directory:
[root#server ~]# ls -l /var/www/html/vhosts/redmine/
total 44
drwxr-xr-x. 7 apache apache 78 Jul 7 16:47 app
drwxr-xr-x. 5 apache apache 4096 Jul 24 08:42 config
-rwxr-xr-x. 1 apache apache 160 Jul 7 16:47 config.ru
-rwxr-xr-x. 1 apache apache 240 Jul 7 16:47 CONTRIBUTING.md
drwxr-xr-x. 3 apache apache 36 Jul 24 08:37 db
drwxr-xr-x. 2 apache apache 107 Jul 7 16:47 doc
drwxr-xr-x. 5 apache apache 55 Jul 7 16:47 extra
drwxrwxr-x. 3 apache nobody 33 Aug 11 15:05 files
-rwxr-xr-x. 1 apache apache 3714 Jul 7 16:47 Gemfile
-rwxr-xr-x. 1 apache apache 3668 Jul 24 08:24 Gemfile.lock
drwxr-xr-x. 8 apache apache 4096 Jul 7 16:47 lib
drwxr-xr-x. 2 apache apache 43 Jul 24 08:36 log
drwxr-xr-x. 2 apache apache 19 Jul 7 16:47 plugins
drwxr-xr-x. 8 apache apache 4096 Jul 24 08:38 public
-rwxr-xr-x. 1 apache apache 275 Jul 7 16:47 Rakefile
-rwxr-xr-x. 1 apache apache 205 Jul 7 16:47 README.rdoc
drwxr-xr-x. 2 apache apache 30 Jul 7 16:47 script
drwxr-xr-x. 9 apache apache 4096 Jul 7 16:46 test
drwxr-xr-x. 8 apache apache 85 Jul 7 16:47 tmp
drwxr-xr-x. 2 apache apache 6 Jul 7 16:47 vendor
I tried to change the user that passenger runs, but had no success. Apparently it has some trouble in centos 7, and this server also runs a gitlab instance, so I quit trying to change it and tryed chmoding and chowning my files directory.
My passenger conf:
[root#server ~]# cat /etc/httpd/conf.d/passenger.conf
LoadModule passenger_module /usr/local/share/gems/gems/passenger-5.0.14/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/share/gems/gems/passenger-5.0.14
PassengerDefaultRuby /usr/bin/ruby
PassengerUser apache
</IfModule>
No matter how I try to change the PassengerUser (also tried PassengerDefaultUser a few times) parameter, I get the "nobody" user to run it:
[root#server ~]# ps aux | grep Passenger
root 2785 0.0 0.2 430108 4604 ? Ssl 15:09 0:00 Passenger watchdog
root 2789 0.0 0.3 645040 6348 ? Sl 15:09 0:00 Passenger core
nobody 2798 0.0 0.2 298768 4676 ? Sl 15:09 0:00 Passenger ust-router
apache 3448 0.0 5.6 414536 106948 ? Sl 15:15 0:00 Passenger RubyApp: /var/www/html/vhosts/redmine
root 4556 0.0 0.0 112640 972 pts/0 R+ 15:26 0:00 grep --color=auto Passenger
You have new mail in /var/spool/mail/root
Did somebody get the same issue? How can I troubleshoot it?
I found out that SELinux was preventing my apache from writing the directory. The solution to keep selinux enforcing was to add the following rule: semanage fcontext -a -t httpd_sys_rw_content_t “/var/www/html/vhosts/redmine/files(/.*)?”, and then apply the settings with restorecon -Rv /var/www/html/vhosts/redmine.
Source: http://www.serverlab.ca/tutorials/linux/web-servers-linux/configuring-selinux-policies-for-apache-web-servers/

Virtual Machine apache not available

Hoping someone can help with this. I have other VM's that dont have problems, so I'm not sure where the problem lies. I dont have any running at the same time.
I CAN ssh in and scp both ways but I cant connect with the browser OR sqldeveloper. Worried more about the browser right now
Guest:
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 2450/httpd
On the host i am forwarding 8081 -> 8081
In httpd.conf I have the port set as 8081
Browser: localhost:8081
not working
hosts file (guest)
127.0.0.1 localhost.localdomain localhost
hostsfile (host)
127.0.0.1 localhost
and....
apache is running.
apache 2700 0.0 0.2 393572 11252 ? S 13:19 0:00 /usr/sbin/httpd
apache 2701 0.0 0.2 393572 11252 ? S 13:19 0:00 /usr/sbin/httpd
What about: sudo /etc/init.d/iptables stop
Have you tried to get your guest IP address and connect directly? On the guest
ifconfig | grep inet
And then shove that into:
http://10.0.1.120:8081/

SVN on Apache failing (errcode="13") Could not open the request SVN filesystem

I have the same symptoms as Error number 13 - Remote access svn with dav_svn failing. However, the solution to that problem does not work for me.
The error message:
<D:error xmlns:D="DAV:" xmlns:m="http://apache.org/dav/xmlns" xmlns:C="svn:">
<C:error/>
<m:human-readable errcode="13">Could not open the requested SVN filesystem</m:human-readable>
</D:error>
The relevant apache log entry:
(20014)Internal error: Can't open file '/svn/testrepo/format': Permission denied
The subversion conf file:
<Location /svn>
DAV svn
SVNPath /svn/testrepo
</Location>
However, I've further confirmed that user apache can, indeed, open the file /svn/testrepo/format, and can not only open it, but move it, duplicate it, delete it, and overwrite it. (su apache -> do all that stuff.) What can I do next?
=========== FURTHER INFORMATION ===========
In response to crazyjul, here are the results of ps aux | grep apache
apache 14019 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
apache 14020 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
apache 14021 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
apache 14022 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
apache 14023 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
apache 14024 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
apache 14025 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
apache 14026 0.0 0.2 11248 2112 ? S 16:40 0:00 /usr/sbin/httpd
root 14032 0.0 0.0 5412 772 pts/4 R+ 16:41 0:00 grep apache
The results of ps aux | grep www
root 14034 0.0 0.0 5412 772 pts/4 S+ 16:42 0:00 grep www
The results of ls -as on my repo folder:
drwxrwxrwx 7 apache apache 4096 2011-10-07 16:13 .
drwxr-xr-x 7 apache apache 4096 2011-10-07 14:04 ..
-rw-r--r-- 1 apache apache 229 2011-10-07 13:50 README.txt
drwxr-xr-x 2 apache apache 4096 2011-10-07 15:50 conf
drwxr-xr-x 2 apache apache 4096 2011-10-07 13:50 dav
drwxr-sr-x 5 apache apache 4096 2011-10-07 14:25 db
-rwxrwxrwx 1 apache apache 2 2011-10-07 13:50 format
drwxr-xr-x 2 apache apache 4096 2011-10-07 13:50 hooks
drwxr-xr-x 2 apache apache 4096 2011-10-07 13:50 locks
I was researching and I find this.
Problably you have SELinux anabled, is a security system that I don't understad very well how does it work exactly but that's the problem. If you want to know if is on type
[root#localhost ~]# getenforce
If says enforcing, is on
In order to deactivate it type
[root#localhost ~]# chcon -R -t httpd_sys_content_t /var/www/svn/your/path
[root#localhost ~]# chcon -R -t httpd_sys_rw_content_t /var/www/svn/your/path
Do you have selinux enabled? I typically disable it for mod_dav_svn but you can get it working with some configuration.
vince#fedora12 /etc/httpd/conf.d > cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
Apache generally have another user to access data. Generally it is called www-data. You can check by calling ps auxand search for apache processes
It is an old thread but I hit the same error message. In my case I was using another hard drive mounted as a repository so that I have to give ownership to www-data entire disk. I found this thread and applied than it worked at https://ubuntuforums.org/archive/index.php/t-1233618.html
sudo chown www-data:www-data /media/yourdisk -R