{"id":3315,"date":"2020-02-11T12:30:00","date_gmt":"2020-02-11T12:30:00","guid":{"rendered":"https:\/\/lamp.ciscoar.com\/?page_id=3315"},"modified":"2020-02-12T01:47:44","modified_gmt":"2020-02-12T01:47:44","slug":"apache-and-firewall","status":"publish","type":"page","link":"https:\/\/lamp.ciscoar.com\/?page_id=3315","title":{"rendered":"Apache and firewall"},"content":{"rendered":"\n\n\n<h2 class=\"wp-block-heading\">Firewall settings by default<\/h2>\n\n\n\n<p>By default the firewall is not configured to allow Apache&#8217;s traffic, you can check which services are on the firewall exception list using the following CLI command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">firewall-cmd --zone=public --list-all<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-05-firewall-entry-missing.png\"><img loading=\"lazy\" decoding=\"async\" width=\"547\" height=\"426\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-05-firewall-entry-missing.png\" alt=\"\" class=\"wp-image-3264\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-05-firewall-entry-missing.png 547w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-05-firewall-entry-missing-300x234.png 300w\" sizes=\"auto, (max-width: 547px) 100vw, 547px\" \/><\/a><figcaption>Firewall exception list<\/figcaption><\/figure><\/div>\n\n\n\n<p>As you can see in the image above, there are only two services on the firewall exception list, DHCPv6-client and SSH, we want to have there also HTTP and HTTPS the last one will be included when configuring the certificates, by now, just adding &#8220;http&#8221; we&#8217;ll be fine. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding Apache to the firewall<\/h2>\n\n\n\n<p>You can permanently add an entry for Apache running the following CLI command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">firewall-cmd --zone=public --permanent --add-service=http<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-06-adding-http-to-firewall.png\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"241\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-06-adding-http-to-firewall.png\" alt=\"\" class=\"wp-image-3268\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-06-adding-http-to-firewall.png 768w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-06-adding-http-to-firewall-300x94.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>Adding Apache &#8220;http&#8221; to the firewall exception list<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Reload firewall to activate changes<\/h2>\n\n\n\n<p>In order to activate the changes you must reload the firewall, and for that you can run the following CLI command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">firewall-cmd --reload<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-07-reload.png\"><img loading=\"lazy\" decoding=\"async\" width=\"409\" height=\"258\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-07-reload.png\" alt=\"\" class=\"wp-image-3272\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-07-reload.png 409w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-07-reload-300x189.png 300w\" sizes=\"auto, (max-width: 409px) 100vw, 409px\" \/><\/a><figcaption>Reloading firewall<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Firewall settings after adding &#8220;http&#8221;<\/h2>\n\n\n\n<p>Let&#8217;s check now once again to see if &#8220;http&#8221; was actually added as an exception to the firewall.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"vim\" class=\"language-vim\">firewall-cmd --zone=public --list-all<\/code><\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-08-after.png\"><img loading=\"lazy\" decoding=\"async\" width=\"547\" height=\"443\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-08-after.png\" alt=\"\" class=\"wp-image-3274\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-08-after.png 547w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-08-after-300x243.png 300w\" sizes=\"auto, (max-width: 547px) 100vw, 547px\" \/><\/a><figcaption>Apache &#8220;http&#8221; was successfully added to the Firewall <\/figcaption><\/figure><\/div>\n\n\n\n<p>You can also add &#8220;<strong>https<\/strong>&#8221; following the same procedure, in our case we are going to do that in a further article, when configuring the certificates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Apache is now working fine<\/h2>\n\n\n\n<p>Now that you know Apache service is up and running and the firewall is configured properly, try again to open the <strong>Apache&#8217;s Test Page<\/strong> using your browser and the IP Address of your CentOS Virtual Machine, you must be able to see the following page:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-09-webpage-ok.png\"><img loading=\"lazy\" decoding=\"async\" width=\"815\" height=\"643\" src=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-09-webpage-ok.png\" alt=\"\" class=\"wp-image-3278\" srcset=\"https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-09-webpage-ok.png 815w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-09-webpage-ok-300x237.png 300w, https:\/\/lamp.ciscoar.com\/wp-content\/uploads\/2020\/02\/linux-centos7-installing-Apache-web-server-09-webpage-ok-768x606.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption>Apache Test Page<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Where to go next?<\/h2>\n\n\n\n<p>You can now move forward to the most important topic you&#8217;ll find when it comes to Apache&#8217;s capabilities, I&#8217;m talking about Virtual Hosts.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/lamp.ciscoar.com\/add-an-apaches-virtual-host\/\">How to add an Apache&#8217;s Virtual Host<\/a><\/li><li><a href=\"https:\/\/lamp.ciscoar.com\/removing-an-apaches-virtual-host\/\">How to remove an Apache&#8217;s Virtual Host<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Firewall settings by default By default the firewall is not configured to allow Apache&#8217;s traffic, you can check which services are on the firewall exception list using the following CLI command. As you can see in the image above, there are only two services on the firewall exception list, DHCPv6-client and SSH, we want to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lamp.ciscoar.com\/?page_id=3315\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Apache and firewall&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3315","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/3315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3315"}],"version-history":[{"count":20,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/3315\/revisions"}],"predecessor-version":[{"id":3425,"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=\/wp\/v2\/pages\/3315\/revisions\/3425"}],"wp:attachment":[{"href":"https:\/\/lamp.ciscoar.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}