Red Hat / CentOS Install nginx PHP5 FastCGI Webserver

How do I install and configure a ngnix FastCGI php5 HTTP / web server under Red Hat / RHEL / Fedora / CentOS Linux?

Nginx (engine x) is an HTTP(S) server, reverse proxy and IMAP/POP3 proxy server written by Igor Sysoev. It is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

Step # 1: Enable EPEL repo

ngnix is not included in the base system. Turn on EPEL repo to install nginx stable release:

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/$(uname -m)/epel-release-5-3.noarch.rpm

Step # 2: Install ngnix

Type the following command at a shell prompt:

# yum install nginx

Sample output:

Loaded plugins: downloadonly, fastestmirror, priorities, protectbase
Loading mirror speeds from cached hostfile
* epel: archive.linux.duke.edu
* base: ftp.linux.ncsu.edu
* updates: centos.mirror.nac.net
* addons: mirror.cs.vt.edu
* extras: centos.mirror.nac.net
0 packages excluded due to repository protections
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:0.6.34-1.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================
Installing:
nginx x86_64 0.6.34-1.el5 epel 319 k
Transaction Summary
==============================================================================================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total size: 319 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : nginx [1/1]
Installed: nginx.x86_64 0:0.6.34-1.el5
Complete!

nginx configuration file

Default config file: /etc/nginx/nginx.conf
Default SSL config file: /etc/nginx/conf.d/ssl.conf
Default virtual hosting config file: /etc/nginx/conf.d/virtual.conf
Default documentroot: /usr/share/nginx/html

Configure PHP As FastCGI

Type the following to install php5 with other modules:
# yum install php-pear-Net-Socket php-pear php-common php-gd php-devel php php-mbstring php-pear-Mail php-cli php-imap php-snmp php-pdo php-xml php-pear-Auth-SASL php-ldap php-pear-Net-SMTP php-mysql
Install spawn-fcgi simple program for spawning FastCGI processes

Type the following command:

# yum install spawn-fcgi

Next, download spawn-fcgi init.d shell script:

# wget http://bash.cyberciti.biz/dl/419.sh.zip
# unzip 419.sh.zip
# mv 419.sh /etc/init.d/php_cgi
# chmod +x /etc/init.d/php_cgi

Start php app server, enter:

# /etc/init.d/php_cgi start
# netstat -tulpn | grep :9000

Sample output:

tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14294/php-cgi

By default php server listens on 127.0.0.1:9000 port. Finally, update /etc/nginx/nginx.conf as follows:

# vi /etc/nginx/nginx.conf

Modify / append as follows:

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}

Save and close the file. Restart nginx:

# service nginx restart

Create /usr/share/nginx/html/test.php with this contain:

<?php  phpinfo(); ?>

Source : http://www.cyberciti.biz/faq/rhel-fedora-install-configure-nginx-php5/

KELIRU, MENGGUNAKAN OBAT PENURUN PANAS SAAT DEMAM

Dikutip dari buku ‘Mukjizat Suhu Tubuh’. Penulis: Masashi Saito. Penerbit: Gramedia Pustaka Utama

“Tidak terbatas hanya ketika kita terserang flu, “menghangatkan badan” merupakan cara sehat yang baik dilakukan setiap saat.

Ketika saya kecil, jika terserang demam dan tidak enak badan, saya pasti disuruh mengenakan 2 helai celana dalam (CD). Jika saya bersin2, batuk, dan menunjukkan gejala terkena flu, nenek bukannya memberikan obat flu, melainkan CD. Jika dipikirkan sekarang (setelah menjadi dokter), saya mengerti bahwa mengenakan 2 CD maksudnya untuk menghangatkan badan.

Tidak hanya dengan melapis CD, boleh juga dengan cara mandi berendam di air hangat, memakai kantong penghangat kecil (kairo), atau memakai botol air panas (yutanpo) pun boleh saja. Yang penting, pada kondisi tubuh kurang fit, upayakan untuk menghangatkan tubuh.

Tetapi banyak orang yang malah melakukan sebaliknya. Contohnya, minum obat flu. … hindarilah langsung minum obat flu, karena itu itu tidak baik bagi tubuh Anda.

Obat flu umumnya bukan untuk menaklukkan virus penyebab flu, melainkan gabungan berbagai macam komposisi obat2an untuk meringankan gejala penyakit. Kebanyakan komposisi obat tersebut menekan kerja saraf parasimpatik dan merangsang saraf simpatik.

Oleh karena itu, jika orang yang sedang kelelahan karena bekerja minum obat flu, peredaran darahnya yang sudah tidak begitu baik malah jadi makin memburuk. Kondisi ini memicu penurunan suhu tubuh (suhu tubuh rendah) dan berisiko menurunkan daya tahan tubuh.

Lebih buruk lagi dari obat flu adalah “obat analgesic antipiretik” (analgesic = pereda nyeri/rasa sakit, anitipiretik = penurun demam). Kebanyakan obat analgesic antipiretik bersifat meningkatkan kinerja saraf simpatik. Tetapi risikonya bukan cuma itu saja. Bahaya obat itu (sesuai namanya) yaitu menurunkan suhu tubuh.

Orang yang se-hari2 bersuhu tubuh rendah dan lemah terhadap demam, bisa saja merasakan lesu dan meriang berat pada suhu tubuh 37oC, sehingga menomorsatukan minum obat penurun demam. Padahal, panas tersebut dibutuhkan untuk meningkatkan daya tahan tubuh guna bertarung melawan virus. Menurunkan demam dengan obat penurun panas merupakan perbuatan keliru, karena menghambat sistem kekebalan tubuh. Inilah sebabnya dokter yang betul2 paham akan risiko obat penurun panas tidak dengan mudah meresepkannya.

Orang yang kurang kuat fisiknya, seperti lansia, adakalanya memerlukan obat penurun panas pada sekitar suhu 38,2 oC. Obat penurun panas yang diberikan pada saat itu adalah jenis yang paling tidak membebani tubuh, yaitu asetaminofen, disesuaikan dosisnya sambil melihat perkembangan pasien, serta diberikan dengan hati2 agar suhu tubuh bertahan pada kisaran 37 oC. … Oleh karena itu, jangan sembarangan minum obat, sekalipun itu obat2an bebas.

Saat ini di AS, jarang sekali dokter meresepkan obat untuk gejala awal flu. Saya sendiri, sebagai dokter, jika terserang flu bukannya minum obat, hanya minum (suplemen) vitamin C dan magnesium. .. Alasannya, vitamin C bekerja paling efektif saat bersama-sama golongan bioflavonoid, kalsium, dan magnesium. Selain itu, magnesium cenderung kurang dapat diambil dari makanan se-hari2, sehingga baik dikonsumsi bersama untuk menggiatkan daya kerja vitamin C.”

ULASAN WIED HARRY:
Membandingkan dengan kebiasaan keluarga Dr. Masashi Saito, kebiasaan keluarga kami pun serupa. Tiap kali kami yang saat itu masih kanak2 mengalami gejala2 akan menderita flu (bersin2, kurang enak badan – “greges2” panas-dingin), ibu kami selalu memberi kami minuman wedang jahe panas. Air seduhan jahe ini harus diminum ketika masih setengah panas atau setelah hangat, tidak boleh diminum setelah dingin.

Nah, kearifan lokal seperti ini saya yakin juga dilakukan masyarakat Indonesia di banyak daerah lainnya untuk menangkal flu, misalnya mungkin di Jawa Barat masyarakat biasa memberikan bandrek atau lebih banyak minum sarabba’ jika di Sulawesi Selatan. Baik bandrek maupun sarabba’ adalah jenis minuman panas (Jawa: wedang) terbuat dari bahan utama jahe dan gula merah.

Dalam jahe terdapat senyawa utama gingerol, yang bersifat menghangatkan. Baik wedang jahe, bandrek, maupun sarabba’ bisa saja “diperkaya” dengan bahan2 bumbu rimpang (empon2) atau rempah2 lainnya, misalnya lengkuas, merica/lada, cengkih, kapulaga, dll. Dan nyatanya, sebagian bahan2 yang ditambahkan ini pun banyak mengandung senyawa aktif “zat pedas” yang bersifat menghangatkan, di antaranya merica/lada berlimpah piperin, cengkih banyak mengandung eugenol dan metil salisilat (yang ini bersifat sebagai pereda nyeri alami), lengkuas kaya akan galangol.

Dan biasanya kalau badan “greges2” mau flu, kita terdorong untuk mengenakan pakaian yang lebih tebal. Bila perlu, masih ditambah dengan “ubel2” di leher seperti yang di foto itu – tentu maksudnya bukan supaya gaya deh, tapi supaya tubuh kita hangat. Zaman kami kecil dulu, ibu kami juga mewajibkan kami mandi air hangat sambil “wuwung” (mengguyur kepala di bagian ubun2 dengan air hangat sambil “di-pyok2” alias di-tepuk2 ringan). Usai mandi, biasanya kami diberi makanan panas yang sedappp, seringnya nasi + sup atau nasi + gulai/kare! Memang betul sih, kombinasi ini cukup mujarab, karena ketika bangun tidur esok harinya badan sudah terasa fit. Tidak ada lagi bersin2 …

Nah, setelah saya tekun menjalani pola makan enak-sehat-alami Food Combining, jika mengalami hal seperti ini otomatis tubuh saya “menolak” makan. Secara alami, mulut hanya menagih diisi buah2an segar dan sayur2an segar sepanjang hari dan bisa berlangsung beberapa hari. Biasanya yang bikin saya sowaq begini adalah jika saya bergabung pada acara orang lain selama beberapa hari, misalnya wisata bareng. [Kebayang dong makannya pasti amburadul! Sebetapapun saya sudah berusaha makan sesehat dan sealami mungkin – bahkan seringkali bawa bekal tomat, paprika, timun, dan buah2an segala, biasanya masih terasa terlalu nakal untuk tubuh saya yang berprinsip “lebih baik seminggu ga ketemu nasi, daripada sehari ga ketemu buah2an dan sayur2an segar”.

Biasanya, beres acara pasti tubuh saya memberikan sinyal: bersin2 parah! plus tenggorokan kering (gara2 kebanyakan terasup MSG). Kalau sudah begini, langsung saya gelontor dengan ber-jerigen2 – hehe engga ding, yang bener adalah ber-mug2 – jus sayuran. Jus sayuran biasanya dari kombinasi caisim, wortel, tomat, dengan/tanpa timun – karena memang sayuran ini yang pasti ada stoknya dalam lemari es, plus tambahan air jeruk lemon. Jus sayuran ini saya minum sesering yang saya suka. Esoknya, gejala flu pasti sudah tak ada jejaknya. Nah, kalau dianalisis, jus sayur campur ini sesuai dengan kebiasaan Dr. Masashi Saito minum suplemen vitamin C dan magnesium, karena zat2 tersebut juga banyak terkandung dalam jus sayuran.

Bagaimana dengan kebiasaan Anda, para Sahabat Sehat? Boleh berbagi cerita

Shalat; Bermanfaat Untuk Ibu Hamil, Bahaya Bagi Wanita Haid

Pernahkah Anda bertanya mengapa kita selaku wanita, masih terus diwajibkan untuk shalat ketika hamil, namun harus berhenti shalat ketika haid? Logikanya, hamil itu berat. Ini dia jawaban menurut medis.

Sejumlah studi medis modern membuktikan bahwa gerak badan dan olah raga seperti shalat banyak memberikan manfaat bagi ibu hamil. Namun justru gerak seperti ini berbahaya bagi wanita haid. Mengapa bisa begitu?

Pada saat wanita melaksanakan shalat, dalam gerakan sujud dan ruku’ secara alamiah akan meningkatkan peredaran darah ke rahim. Karena kebutuhan sel-sel rahim dan indung telur seperti sel-sel limpa yang menyedot banyak darah.

Begitu juga saat seorang ibu hamil, rahim membutuhkan darah melimpah agar janin mendapatkan gizi dan untuk membersihkan polusi. Jika seorang ibu hamil menjalankan shalat, aktifitasnya ini akan membantunya mengantarkan darah yang melimpah ke janin.

Sementara wanita yang haid, jika menunaikan shalat, akan menyebabkan banyak darah mengalir ke rahimnya. Akibatnya, ia akan kehilangan darah bersih/baik karena keluar bersama darah haid.

Di masa haid, diperkirakan wanita kehilangan darahnya sebanyak 34 mililiter. Kadar yang sama pada cairan lainnya. Jika wanita haid menunaikan shalat, zat imunitas (kekebalan) di tubuhnya akan hancur. Sebab sel darah putih berperan sebagai imun akan hilang terbawa bersama darah haid.

Mengalirnya darah secara umum akan meningkatkan kemungkinan menularnya penyakit. Namun Allah menjaga wanita haid dari penularan penyakit dengan mengkonsentrasikan sel darah putih di rahim selama masa haid agar menjaga tubuh dan melawan berbagai penyakit.

Jika seorang wanita shalat saat haid, maka ia akan kehilangan darah dalam jumlah banyak. Ini berarti akan kehilangan sel darah putih. Jika ini terjadi maka seluruh organ tubuhnya seperti limpa dan otak akan terserang penyakit.

Mungkin inilah hikmah besar di balik larangan syariat agar wanita haid tidak melaksanakan shalat hingga ia suci. Al-Quran dengan sangat cermat menyebutkan,

“Mereka bertanya kepadamu tentang haidh. Katakanlah: “Haidh itu adalah suatu kotoran.” Oleh sebab itu, hendaklah kamu menjauhkan diri dari wanita di waktu haidh; dan janganlah kamu mendekati mereka, sebelum mereka suci.” (Al-Baqarah: 222).

Disamping itu, gerak fisik saat sujud dan ruku’ semakin menambah aliran darah ke rahim dan akan hilang percuma. Lebih dari itu, jika wanita haid shalat maka akan menyebabkan kekurangan zat logam dari tubuh.

Begitu juga dengan larangan shaum pada saat haidh. Para medis menganjurkan agar ketika dalam keadaan haid, wanita banyak beristirahat dan mengkonsumsi makanan yang bergizi. Ini sejalan dengan larangan untuk shaum, karena menurut medis agar darah dan logam seperti magnesium dan zat besi dalam tubuh yang berharga tidak terbuang percuma.

Dari Abu Said Al-Hudri, Rasulullah SAW bersabda: “.Bukankah jika (seorang wanita) haid ia tidak shalat dan tidak puasa?” (HR. Bukhari dan Muslim).

Dari Aisyah, Rasulullah SAW bersabda,”Kami diperintahkan untuk mengqadla puasa dan tidak mengqadla shalat.”

Betapa banyak tanda-tanda yang Allah SWT berikan kepada umat manusia supaya berpikir. Allah SWT yang begitu penyayangnya terhadap manusia, sehingga segala hal yang Ia perintahkan dan Ia larang pasti ada hikmah di balik semuanya. Maka apalagi yang kita tunggu dan pertimbangkan untuk segera menaati segala aturan yang telah ditentukan oleh-Nya. Wallahu a’lam. [berbagai sumber]

Sumber :
http://rumahkeluarga-indonesia.com/shalat-bermanfaat-untuk-ibu-hamil-bahaya- bagi-wanita-haid-2034/

Access Control List on Oracle 11

Create an Access Control List (ACL)

Access control lists are manipulated using the DBMS_NETWORK_ACL_ADMIN package. The CREATE_ACL procedure uses the following parameters to create a new ACL:

  • acl – The name of the access control list XML file, generated relative to the “/sys/acls” directory in the XML DB Repository.
  • description – A description of the ACL.
  • principal – The first user account or role being granted or denied permissions. The text is case sensitive.
  • is_grant – TRUE to grant, FALSE to deny the privilege.
  • privilege – Use ‘connect’ for UTL_TCP, UTL_SMTP, UTL_MAIL and UTL_HTTP access. Use ‘resolve’ for UTL_INADDR name/IP resolution. The text is case sensitive.
  • start_date – Default value NULL. When specified, the ACL will only be active on or after the specified date.
  • end_date – An optional end date for the ACL.

The following code creates two test users to act as principals, then creates a new ACL.

CONN sys/password@db11g AS SYSDBA

CREATE USER test1 IDENTIFIED BY test1;
GRANT CONNECT TO test1;

CREATE USER test2 IDENTIFIED BY test2;
GRANT CONNECT TO test2;

BEGIN
  DBMS_NETWORK_ACL_ADMIN.create_acl (
    acl          => 'test_acl_file.xml', 
    description  => 'A test of the ACL functionality',
    principal    => 'TEST1',
    is_grant     => TRUE, 
    privilege    => 'connect',
    start_date   => SYSTIMESTAMP,
    end_date     => NULL);

  COMMIT;
END;
/

Once created, the ACL is visible in the “http://host:port/sys/acls/&#8221; directory.

Additional users or roles are added to the ACL using the ADD_PRIVILEGE procedure. Its parameter list is similar to the CREATE_ACL procedure, with the omission of the DESCRIPTION parameter and the addition of a POSITION parameter, which sets the order of precedence.

BEGIN
  DBMS_NETWORK_ACL_ADMIN.add_privilege ( 
    acl         => 'test_acl_file.xml', 
    principal   => 'TEST2',
    is_grant    => FALSE, 
    privilege   => 'connect', 
    position    => NULL, 
    start_date  => NULL,
    end_date    => NULL);

  COMMIT;
END;
/

Each principal is defined as a separate access control element (ACE), within the ACL. When multiple principles are defined, they are evaluated in order from top to bottom, with the last relevant reference used to define the privilege. This means a role that denies access to a resource can be granted to a user, but if the user is defined as a principal further down the file, that definition will override the role definition for that user. Use the POSITION parameter to ensure privileges are evaluated in order.

Privileges are removed using the DELETE_PRIVILEGE procedure. If the IS_GRANT or PRIVILEGE parameters are NULL, all grants or privileges for the ACL and principal are removed.

BEGIN
  DBMS_NETWORK_ACL_ADMIN.delete_privilege ( 
    acl         => 'test_acl_file.xml', 
    principal   => 'TEST2',
    is_grant    => FALSE, 
    privilege   => 'connect');

  COMMIT;
END;
/

ACLs are deleted using the DROP_ACL procedure.

BEGIN
  DBMS_NETWORK_ACL_ADMIN.drop_acl ( 
    acl         => 'test_acl_file.xml');

  COMMIT;
END;
/

Assign an ACL to a Network

Access control lists are assigned to networks using the ASSIGN_ACL procedure, whose parameters are listed below:

  • acl – The name of the access control list XML file.
  • host – The hostname, domain, IP address or subnet to be assigned. Hostnames are case sensitive, and wildcards are allowed for IP addresses and domains.
  • lower_port – Defaults to NULL. Specifies the lower port range for the ‘connect’ privilege.
  • upper_port – Defaults to NULL. If the lower_port is specified, and the upper_port is NULL, it is assumed the upper_port matches the lower_port.

The code below shows the ACL created previously being assigned to a specific IP address and a subnet.

BEGIN
  DBMS_NETWORK_ACL_ADMIN.assign_acl (
    acl         => 'test_acl_file.xml',
    host        => '192.168.2.3', 
    lower_port  => 80,
    upper_port  => NULL); 

  DBMS_NETWORK_ACL_ADMIN.assign_acl (
    acl         => 'test_acl_file.xml',
    host        => '10.1.10.*', 
    lower_port  => NULL,
    upper_port  => NULL);

  COMMIT;
END;
/

Only one ACL can be assigned to a specific host and port-range combination. Assigning a new ACL to a specific host and port-range results in the deletion of the previous assignment. You must take care when making a new assignment that you are not opening ports that were closed by a previous ACL assignment, or you could be opening yourself to attack. When wildcard usage causes overlapping assignments, the most specific assignment will take precedence, so an ACL assigned to 192.168.2.3:80 takes precedence over once assigned to 192.168.2.* etc.

The UNASSIGN_ACL procedure allows you to manually drop ACL assignments. It uses the same parameter list as the ASSIGN_ACL procedure, with any NULL parameters acting as wildcards.

BEGIN
  DBMS_NETWORK_ACL_ADMIN.unassign_acl (
    acl         => 'test_acl_file.xml',
    host        => '192.168.2.3', 
    lower_port  => 80,
    upper_port  => NULL); 

  COMMIT;
END;
/

ACL Views

The DBA_NETWORK_ACLS, DBA_NETWORK_ACL_PRIVILEGES and USER_NETWORK_ACL_PRIVILEGES views display the current ACL settings. The expected output below assumes none of the delete/drop/unassign operations have been performed.

The DBA_NETWORK_ACLS view displays information about network and ACL assignments.

COLUMN host FORMAT A30
COLUMN acl FORMAT A30

SELECT host, lower_port, upper_port, acl
FROM   dba_network_acls;

HOST                           LOWER_PORT UPPER_PORT ACL
------------------------------ ---------- ---------- ------------------------------
10.1.10.*                                            /sys/acls/test_acl_file.xml
192.168.2.3                            80         80 /sys/acls/test_acl_file.xml

2 rows selected.

SQL>

The DBA_NETWORK_ACL_PRIVILEGES view displays information about privileges associated with the ACL.

COLUMN acl FORMAT A30
COLUMN principal FORMAT A30

SELECT acl,
       principal,
       privilege,
       is_grant,
       TO_CHAR(start_date, 'DD-MON-YYYY') AS start_date,
       TO_CHAR(end_date, 'DD-MON-YYYY') AS end_date
FROM   dba_network_acl_privileges;

ACL                            PRINCIPAL                      PRIVILE IS_GR START_DATE  END_DATE
------------------------------ ------------------------------ ------- ----- ----------- -----------
/sys/acls/test_acl_file.xml    TEST1                          connect true  02-APR-2008
/sys/acls/test_acl_file.xml    TEST2                          connect false

2 rows selected.

SQL>

The USER_NETWORK_ACL_PRIVILEGES view displays the current users network ACL settings.

CONN test1/test1@db11g

COLUMN host FORMAT A30

SELECT host, lower_port, upper_port, privilege, status
FROM   user_network_acl_privileges;

HOST                           LOWER_PORT UPPER_PORT PRIVILE STATUS
------------------------------ ---------- ---------- ------- -------
10.1.10.*                                            connect GRANTED
192.168.2.3                            80         80 connect GRANTED

2 rows selected.

SQL> 

CONN test2/test2@db11g

COLUMN host FORMAT A30

SELECT host, lower_port, upper_port, privilege, status
FROM   user_network_acl_privileges;

HOST                           LOWER_PORT UPPER_PORT PRIVILE STATUS
------------------------------ ---------- ---------- ------- -------
10.1.10.*                                            connect DENIED
192.168.2.3                            80         80 connect DENIED

2 rows selected.

SQL>

Checking Privileges

In addition to the ACL views, privileges can be checked using the CHECK_PRIVILEGE and CHECK_PRIVILEGE_ACLID functions of the DBMS_NETWORK_ACL_ADMIN package.

CONN sys/password@db11g AS SYSDBA

SELECT DECODE(
         DBMS_NETWORK_ACL_ADMIN.check_privilege('test_acl_file.xml', 'TEST1', 'connect'),
         1, 'GRANTED', 0, 'DENIED', NULL) privilege 
FROM dual;

PRIVILE
-------
GRANTED

1 row selected.

SQL> 

COLUMN acl FORMAT A30
COLUMN host FORMAT A30

SELECT acl,
       host,
       DECODE(
         DBMS_NETWORK_ACL_ADMIN.check_privilege_aclid(aclid, 'TEST2', 'connect'),
         1, 'GRANTED', 0, 'DENIED', NULL) privilege 
FROM   dba_network_acls;

PRIVILE
-------
DENIED

1 row selected.

SQL>

The DBMS_NETWORK_ACL_UTILITY package contains functions to help determine possible matching domains. The DOMAINS table function returns a collection of all possible references that may affect the specified host, domain, IP address or subnet, in order of precedence.

SELECT *
FROM   TABLE(DBMS_NETWORK_ACL_UTILITY.domains('oel5-11g.localdomain'));
         
COLUMN_VALUE
-------------------------------
oel5-11g.localdomain
*.localdomain
*

3 rows selected.

SQL>

SELECT *
FROM   TABLE(DBMS_NETWORK_ACL_UTILITY.domains('192.168.2.3'));

COLUMN_VALUE
-------------------------------
192.168.2.3
192.168.2.*
192.168.*
192.*
*

5 rows selected.

SQL>

The DOMAIN_LEVEL function returns the level of the specified host, domain, IP address or subnet.

SELECT DBMS_NETWORK_ACL_UTILITY.domain_level('oel5-11g.localdomain')
FROM   dual;

DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL('OEL5-11G.LOCALDOMAIN')
-------------------------------------------------------------
                                                            2

1 row selected.

SQL> 

SELECT DBMS_NETWORK_ACL_UTILITY.domain_level('192.168.2.3')
FROM   dual;

DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL('192.168.2.3')
----------------------------------------------------
                                                   4

1 row selected.

SQL>

These functions may be useful for when querying the ACL views for possible matches to a specific host, domain, IP address or subnet.

SELECT host,
       lower_port,
       upper_port,
       acl,
       DECODE(
         DBMS_NETWORK_ACL_ADMIN.check_privilege_aclid(aclid,  'TEST1', 'connect'),
         1, 'GRANTED', 0, 'DENIED', null) PRIVILEGE
FROM   dba_network_acls
WHERE  host IN (SELECT *
                FROM   TABLE(DBMS_NETWORK_ACL_UTILITY.domains('10.1.10.191')))
ORDER BY 
       DBMS_NETWORK_ACL_UTILITY.domain_level(host) desc, lower_port, upper_port;
  
HOST                           LOWER_PORT UPPER_PORT ACL                            PRIVILE
------------------------------ ---------- ---------- ------------------------------ -------
10.1.10.*                                            /sys/acls/test_acl_file.xml    GRANTED

1 row selected.

SQL>

Test the ACL

The TEST1 and TEST2 users have the ACL allowed and denied respectively. This means we can test the ACL functionality by comparing their responses to calls to external network services. The following code grants execute permission on the UTL_HTTP package to both users, then attempts to access a web page from each user.

CONN sys/password@db11g AS SYSDBA
GRANT EXECUTE ON UTL_HTTP TO test1, test2;

CONN test1/test1@db11g

DECLARE
  l_url            VARCHAR2(50) := 'http://192.168.2.3:80';
  l_http_request   UTL_HTTP.req;
  l_http_response  UTL_HTTP.resp;
BEGIN
  -- Make a HTTP request and get the response.
  l_http_request  := UTL_HTTP.begin_request(l_url);
  l_http_response := UTL_HTTP.get_response(l_http_request);
  UTL_HTTP.end_response(l_http_response);
END;
/

PL/SQL procedure successfully completed.

SQL>

CONN test2/test2@db11g

DECLARE
  l_url            VARCHAR2(50) := 'http://192.168.2.3:80';
  l_http_request   UTL_HTTP.req;
  l_http_response  UTL_HTTP.resp;
BEGIN
  -- Make a HTTP request and get the response.
  l_http_request  := UTL_HTTP.begin_request(l_url);
  l_http_response := UTL_HTTP.get_response(l_http_request);
  UTL_HTTP.end_response(l_http_response);
END;
/
DECLARE
*
ERROR at line 1:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1029
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at line 7


SQL>

From this we can see that the TEST1 user was able to access the web page, while the TEST2 user was denied access by the ACL.

The default action of the server is to deny access to external network service, as shown by the following test on a new user.

CONN sys/password@db11g AS SYSDBA

CREATE USER test3 IDENTIFIED BY test3;
GRANT CONNECT TO test3;
GRANT EXECUTE ON UTL_HTTP TO test3;

CONN test3/test3@db11g

DECLARE
  l_url            VARCHAR2(50) := 'http://192.168.2.3:80';
  l_http_request   UTL_HTTP.req;
  l_http_response  UTL_HTTP.resp;
BEGIN
  -- Make a HTTP request and get the response.
  l_http_request  := UTL_HTTP.begin_request(l_url);
  l_http_response := UTL_HTTP.get_response(l_http_request);
  UTL_HTTP.end_response(l_http_response);
END;
/
DECLARE
*
ERROR at line 1:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1029
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at line 7


SQL>

This may cause some confusion when upgrading databases that access external network services from 10g to 11g. In these situations, it will be necessary to implement suitable access control lists before your original functionality is possible.

Other Security Considerations

Pete Finnigan commented on his blog and in his security presentations about the fact that the ACLs are not tied to a specific package. This means opening a port on a server with the ‘connect’ privilege makes it accessible by UTL_TCP, UTL_SMTP, UTL_MAIL and UTL_HTTP. With this in mind there are some things to consider:

  • The use of fine-grained access to network services is not an excuse to ignore basic security measures, like revoking unnecessary privileges on network service related packages.
  • Control over the services you make available is possible by limiting access to the specific ports. If you only need HTTP access to port 80, specify the port rather than opening access to all ports on the server.
  • Wildcards can be dangerous as you may be granting access to more servers that you should.
  • You must protect your ACLs. If people can alter them, they become useless as a protection mechanism. Prevent direct access to the ACLs in the XML DB repository and make sure users don’t have access to the management APIs.

Thanks to Pete Finnigan for his input.

Open ACL

From a security standpoint, it’s not a good idea to allow complete network access from the database, but for testing features I sometimes find it useful to create an open ACL for an instance.

CONN / AS SYSDBA
BEGIN
  DBMS_NETWORK_ACL_ADMIN.create_acl (
    acl          => 'open_acl_file.xml', 
    description  => 'A test of the ACL functionality',
    principal    => 'TEST',
    is_grant     => TRUE, 
    privilege    => 'connect',
    start_date   => SYSTIMESTAMP,
    end_date     => NULL);

  DBMS_NETWORK_ACL_ADMIN.assign_acl (
    acl         => 'open_acl_file.xml',
    host        => '*', 
    lower_port  => 1,
    upper_port  => 9999); 

  COMMIT;
END;
/

source : http://www.oracle-base.com/articles/11g/fine-grained-access-to-network-services-11gr1.php

Lost APEX ADMIN password?

You need to locate and run the file
C:\oraclexe\app\oracle\product\11.2.0\server\apex\apxchpwd.sql

If you are running your database in Linux, find the apxchpwd.sql file by

$ locate apxchpwd.sql

Then go to that directory and run SQLPlus.

Follow these instructions to recover your ADMIN password. Note this is not for reseting your workspace ADMIN account password. Its for resetting the password for ADMIN account for your entire APEX installation. Open command prompt and cd to
C:\oraclexe\app\oracle\product\11.2.0\server\apex
Run sqlplus from command prompt.
Run the command alter session set current_schema=’apex_040000′; Run the command @apxchpwd.sql and enter your password.

You should now be able to log into http://localhost:8080/apex/apex_admin. APEX will ask you change your password again after logging in.

Source :
http://techxploration.blogspot.com/2011/12/lost-apex-admin-password.html