{"id":6833,"date":"2017-07-05T12:04:43","date_gmt":"2017-07-05T04:04:43","guid":{"rendered":"http:\/\/rmohan.com\/?p=6833"},"modified":"2017-07-05T12:04:43","modified_gmt":"2017-07-05T04:04:43","slug":"sudo-and-apache","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6833","title":{"rendered":"Sudo And apache"},"content":{"rendered":"<p>a. login as root<\/p>\n<p>b. Edit the sudoers file u uusing visudo command<br \/>\nvisudo<br \/>\nEnsure the following is in the file if # is there infront of the line then remove it. Save the file hit esc key the : wq<br \/>\n## Allows people in group wheel to run all commands<br \/>\n%wheel ALL=(ALL) ALL<\/p>\n<p>c. Add users to wheel<br \/>\nusermod -aG wheel test<br \/>\nusermod -aG wheel test1<br \/>\nusermod -aG wheel test2.<\/p>\n<p>8 Fallback<\/p>\n<p>Time Activity Owner<br \/>\nAccess rights can be remove again by removing the user from wheel group.<br \/>\nid -nG &lt;username&gt; &#8212; This will list all the secondary group of the user<br \/>\nusermod \u2013G group1 group2 &lt;username&gt; &#8212; Keyin all the secondary groups except wheel<br \/>\nOr you can directly edit the \/etc\/group file and remove the username from the wheel group<\/p>\n<p># cat \/etc\/group |grep -i wheel<br \/>\nwheel:x:10:root,test<br \/>\nvi \/etc\/group navigate to the wheel group and remove the user. Example &lt;test&gt;<\/p>\n<p>Configuration of Reverse Proxy<\/p>\n<p>Steps for ssl<\/p>\n<p>FIRST TAKE a backup of apache config folder and cert.<\/p>\n<p>cp rmohan.com.conf rmohan.com.conf_13062017<br \/>\ncp -pR \/etc\/httpd\/conf.d\/cert \/etc\/httpd\/conf.d\/cert_13062017<br \/>\nStep 2<\/p>\n<p>Unzip the cert.zip<br \/>\n\/root\/cert<br \/>\nchange the file extenstion .txt to intermediate_ca.crt root_ca.crt rmohan.com_com_ee.crt<br \/>\ncopy the key file PrivateKey.key \/root\/cert<br \/>\nStep 3<br \/>\nTo combine them, run the following command in terminal:<br \/>\ncd \/root\/cert\/<br \/>\n$ cat intermediate_ca.crt root_ca.crt &gt;&gt; bundle.crt<br \/>\nStep 4<\/p>\n<p>apachectl stop<\/p>\n<p>Step 5<\/p>\n<p>copy \/root\/cert\/bundle.crt to \/etc\/httpd\/conf.d\/cert\/bundle.crt<br \/>\ncp rmohan.com_com_ee.crt \/etc\/httpd\/conf.d\/cert\/rmohan.com_com_ee.crt<br \/>\ncp PrivateKey.key \/etc\/httpd\/conf.d\/cert\/rmohan.com_com_RSA_private.key<br \/>\nSSLCACertificateFile &#8220;\/etc\/httpd\/conf.d\/cert\/bundle.crt&#8221;<br \/>\nSSLCertificateFile &#8220;\/etc\/httpd\/conf.d\/cert\/rmohan.com_com_ee.crt&#8221;<br \/>\nSSLCertificateKeyFile &#8220;\/etc\/httpd\/conf.d\/cert\/rmohan.com_com_RSA_private.key&#8221;<br \/>\nStep 6<\/p>\n<p>apachectl start<\/p>\n<p>we can use 2 methods<\/p>\n<p>First method<\/p>\n<p>How to generate x509 SHA256 hash self-signed certificate using OpenSSL<\/p>\n<p>openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout rmohan.com_com_RSA_private.key -out rmohan.com_com_ee.crt<\/p>\n<p>openssl x509 -noout -text -in rmohan.com_com_ee.crt<br \/>\nsecond method<\/p>\n<p>Create A Self-Signed SSL Certificate With OpenSSL<br \/>\nopenssl req -x509 -sha256 -newkey rsa:2048 -keyout rmohan.com_com_RSA_private.key -out rmohan.com_com_ee.crt -days 1024 -nodes<br \/>\ngenerating a 2048 bit RSA private key<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..+++<br \/>\n&#8230;&#8230;&#8230;&#8230;..+++<br \/>\nwriting new private key to &#8216;rmohan.com_com_RSA_private.key&#8217;<br \/>\n&#8212;&#8211;<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your rmohan.com_com_RSA_private request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter &#8216;.&#8217;, the field will be left blank.<br \/>\n&#8212;&#8211;<br \/>\nCountry Name (2 letter code) [AU]:SG<br \/>\nState or Province Name (full name) [Some-State]:Singapore<br \/>\nLocality Name (eg, city) []:Singapore<br \/>\nOrganization Name (eg, company) [Internet Widgits Pty Ltd]:Singapore Telecommunications Limited<br \/>\nOrganizational Unit Name (eg, section) []:Networks<br \/>\nCommon Name (e.g. server FQDN or YOUR name) []: smp.smart.singtel.com<br \/>\nEmail Address []:admin@singtel.com<br \/>\nopenssl req -x509 -sha256 -newkey rsa:2048 -keyout rmohan.com_com_RSA_private.key -out rmohan.com_com_ee.crt -days 1024 -nodes -subj &#8216;\/CN=smp.smart.singtel.com&#8217;<br \/>\nVerify sha256 hash function in self-signed x509 digital certificate<\/p>\n<p>openssl x509 -noout -text -in rmohan.com_com_ee.crt<br \/>\nThe Nginx front end distributes the method according to $remote_addr<br \/>\nRequirements are as follows:<br \/>\nThere are multiple servers under the domain name, is a test for a region, so that a region of the ip user only visit a server, a separate test, if no problem, all updated; problems are less affected,<br \/>\nTimely find the problem to solve the problem;<\/p>\n<p>Solution:<br \/>\nThe use of nginx module, in the front-end load balancing on the machine, configure the matching rules;<br \/>\nnginx configuration vhost inside, domain name below the location section, add a code<br \/>\nIf $remote_addr match ip, then forwarded to abc_test_server;<br \/>\nserver {<br \/>\nlisten 80;<br \/>\nserver_name rmohan.com;<br \/>\naccess_log \/dev\/null;<br \/>\nerror_log \/data\/logs\/error.log;<\/p>\n<p>location \/ {<\/p>\n<p>proxy_set_header Host $host;<br \/>\nproxy_set_header X-Real-IP $remote_addr;<br \/>\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\nif ($remote_addr ~ &#8220;202.96.134.100&#8221;)<br \/>\n{<br \/>\nproxy_pass http:\/\/test_server;<br \/>\nbreak;<br \/>\n}<br \/>\nproxy_pass http:\/\/abc_server;<br \/>\n}<br \/>\n}<\/p>\n<p>#abc_test only<br \/>\nupstream test_server {<br \/>\nserver 192.168.2.10:80;<\/p>\n<p>}<br \/>\n#rmohan.com<br \/>\nupstream app_server {<br \/>\nserver 192.168.2.11:80;<br \/>\nserver 192.168.2.12:80;<br \/>\nserver 192.168.2.13:80;<br \/>\n}<\/p>\n<p>Will send an email now for the development<\/p>\n","protected":false},"excerpt":{"rendered":"<p>a. login as root<\/p>\n<p>b. Edit the sudoers file u uusing visudo command visudo Ensure the following is in the file if # is there infront of the line then remove it. Save the file hit esc key the : wq ## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL<\/p>\n<p>c. [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6833"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6833"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6833\/revisions"}],"predecessor-version":[{"id":6834,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6833\/revisions\/6834"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}