The Passenger RPM contains an SELinux policy. We currently have no automated tests for this because SELinux does not work inside Docker containers. So here is the procedure for manually testing SELinux. All commands must be run as a normal user unless otherwise indicated.
For your convenience, there use the Vagrantfile in the vagrant-centos/
directory to spin up a CentOS VM.
- Edit /etc/selinux/config. Make sure
SELINUX
is set toenforcing
. - Run
sestatus
. Check that SELinux is enabled and set to enforcing. If it isn't, reboot. - If you rebooted, run
sestatus
again. Check that SELinux is enabled and set to enforcing.
This account can have any name. It must have sudo access. Throughout this document we will refer to this user as '$USER'.
sudo mkdir -p /app /app/public
echo 'run lambda { |env| [200, {}, ["ok\n"]] }' | sudo tee /app/config.ru
sudo chown -R $USER: /app
sudo chcon -R -t httpd_sys_content_t /app
Edit /etc/hosts. Ensure that it contains:
127.0.0.1 rack.test
Run:
sudo yum install httpd
On CentOS/RHEL 6:
sudo mkdir -p /etc/httpd/conf.d /etc/nginx/conf.d
cat <<EOF | sudo tee /etc/httpd/conf.d/app.conf
<VirtualHost *:80>
ServerName rack.test
DocumentRoot /app/public
</VirtualHost>
EOF
cat <<EOF | sudo tee /etc/nginx/conf.d/app.conf
server {
listen 80;
server_name rack.test;
root /app/public;
passenger_enabled on;
}
EOF
On CentOS/RHEL 7:
sudo mkdir -p /etc/httpd/conf.d /etc/nginx/conf.d
cat <<EOF | sudo tee /etc/httpd/conf.d/app.conf
<VirtualHost *:80>
ServerName rack.test
DocumentRoot /app/public
<Directory /app/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache > 2.4:
Require all granted
</Directory>
</VirtualHost>
EOF
cat <<EOF | sudo tee /etc/nginx/conf.d/app.conf
server {
listen 80;
server_name rack.test;
root /app/public;
passenger_enabled on;
}
EOF
- (Re)install the
passenger
RPM. - Run
sudo semodule -l | grep passenger
. Check that the Passenger module appears in the list, and that its version equals the version specified in thepolicy_module(.,.)
statement inspecs/passenger/passenger.te
. - Run
ls -Z /usr/lib64/passenger/support-binaries/PassengerAgent
. Check that it has thepassenger_exec_t
type.
- Ensure the
mod_passenger
RPM is installed. - Empty the Apache error log:
sudo sh -c 'echo -n > /var/log/httpd/error_log'
- Ensure Nginx is stopped, e.g.:
sudo service nginx stop
- Restart Apache:
sudo service httpd restart
- Run
ps auxwZ | grep 'Passenger core' | grep -v grep
. Check that it has theunconfined_t
domain. - Run
sudo cat /var/log/httpd/error_log
. Check that there are no error messages.
- Ensure the
mod_passenger
RPM is installed. - Ensure Nginx is stopped, e.g.:
sudo service nginx stop
- Ensure Apache is started, e.g.:
sudo service httpd start
- Access the test app:
curl http://rack.test
. Check that it printsok
. - Run
ps auxwZ | grep RubyApp | grep -v grep
. Check that all RubyApp processes have theunconfined_t
domain.
- Ensure that our
nginx
RPM is installed (and not the one by the distribution). - Ensure that /etc/nginx/conf.d/passenger.conf enables Passenger.
- Empty the Nginx error log:
sudo sh -c 'echo -n > /var/log/nginx/error.log'
- Ensure Apache is stopped, e.g.:
sudo service httpd stop
- Restart Nginx:
sudo service nginx restart
- Run
ps auxwZ | grep 'Passenger core' | grep -v grep
. Check that it has theunconfined_t
domain. - Run
sudo cat /var/log/nginx/error.log
. Check that there are no error messages.
- Ensure that our
nginx
RPM is installed (and not the one by the distribution). - Ensure that /etc/nginx/conf.d/passenger.conf enables Passenger.
- Ensure Apache is stopped, e.g.:
sudo service httpd stop
- Ensure Nginx is started, e.g.:
sudo service nginx start
- Access the test app:
curl http://rack.test
. Check that it printsok
. - Run
ps auxwZ | grep RubyApp | grep -v grep
. Check that all RubyApp processes have theunconfined_t
domain.