Indonesian Back|Track Team
Share Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - Printable Version

+- Indonesian Back|Track Team (https://www.indonesianbacktrack.or.id/forum)
+-- Forum: General Zone (https://www.indonesianbacktrack.or.id/forum/forum-172.html)
+--- Forum: Operating System Discuss (https://www.indonesianbacktrack.or.id/forum/forum-174.html)
+---- Forum: Free BSD (https://www.indonesianbacktrack.or.id/forum/forum-60.html)
+---- Thread: Share Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 (/thread-6292.html)

Pages: 1 2 3


Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - ino_ot - 06-13-2015

hehehe, lumayan yang kena trap dari thread ini, Maaf ya soalnya koneksi internet dirumah lagi kacau, Makanya ane kasih coming soon dulu. 

Baik di postingan kali ini ane membagi sebuah teknik or trik dari 2 buah web server yang tidak aneh lagi di telinga temen - temen IBTeam. Udah berkeliaran banyak sih di google, tapi alangkah baiknya jika ane ringkas disini, hehehe semoga tidak repost yang mas momod.

Baik Sesuai dengan judul ane pengen ngasih sedikit trik agar dua webserver ini bisa berjalan dalam 1 server dengan memakai fungsi dan keunggulan dari masing - masing webserver tersebut.

Nginx As a Reverse Proxy For Apache on FreeBSD 10.1

Baik Sebagai pembukaan silakan cek Thread ini, Untuk kelebihan Masing - masing webser

https://indonesianbacktrack.or.id/forum/thread-5734.html?highlight=nginx

Nah setelah baca itu, silakan simak baik - baik cara konfigurasinya hehehe
Satu  lagi, ada beberapa yang bilang agar tidak bisa di attack dengan slowrolis

Spoiler! :

Update Portsnap
Code:
# portsnap extract
# portsnap fetch update


Spoiler! :


Install Apache
Code:
# pkg install apache24

Enable apache sebagai service tambahkan "apache24_enable=YES" di /etc/rc.conf, tapi kita menggunakan sysrc seperti dibawah ini.
Code:
# sysrc apache24_enable=YES

Jalankan Apache24
Code:
# service apache start



Spoiler! :

Install Mysql Versi Terbaru -. Mysql 5.6
Code:
# pkg install mysql56-server

Enable Mysql Service
Code:
# sysrc mysql_enable=YES

Jalankan Mysql Server
Code:
# service mysql-server start

Berikan Password untuk login user mysql
Code:
# mysql_secure_installation
Silakan baca baik2 yang ada di dialog mysql nantinya =)



Spoiler! :

Install PHP Versi Terbaru -> php 5.6
Code:
# pkg install mod_php56 php56-mysql php56-mysqli

Copy php.ini
Code:
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Jalankan Rehash untuk mengenerate cache sistem
Code:
rehash

Konfigurasi apache agar bisa membaca file .php

Code:
# nano /usr/local/etc/apache24/httpd.conf

Cari Line Directory Index, dan tambahan index.php di line tersebut, contoh :
Code:
DirectoryIndex index.php index.html index.htm

Tambahkan ini di baris terakhir file, agar apache bisa membaca file php dari php processor
Code:
<FilesMatch "\.php$">
   SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
   SetHandler application/x-httpd-php-source
</FilesMatch>


JIka Dengan Konfigurasi diatas php tidak mau terpanggil maka ganti dengan ini :
Code:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps



Spoiler! :

Install Nginx
Code:
# pkg install nginx

Enable Service
Code:
# sysrc nginx_enable=YES

Jalankan Nginx
Code:
# service nginx start




Spoiler! :

Nah agar si nginx bisa menjadi reverse proxy dari apache, maka kita harus install mod tambahan dari apache yaitu mod_rpaf
Code:
# cd /usr/ports/www/mod_rpaf2/
# make install clean

Setelah diinstall kita aktifkan mod tersebut lewat httpd.conf
Code:
# nano /usr/local/etc/apache24/httpd.conf

Hapus # dari
Code:
LoadModule rpaf_module libexec/apache24/mod_rpaf.so

tambahkan script ini dibawah LoadModule
Code:
RPAFenable On
RPAFsethostname On
RPAFproxy_ips IP-Server
RPAFheader x-Forwarded-For


Spoiler! :

konfigurasi Nginx 

Code:
#user  nobody;

worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
        access_log /var/log/nginx/access.log;
    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    proxy_cache_path    /var/nginx/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
    proxy_temp_path     /var/nginx/cache/tmp;
    proxy_cache_key     "$scheme$host$request_uri";

    gzip  on;

    server {
        #listen       880;
        server_name  _;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /nginx_status {

location /nginx_status {

                stub_status on;
                access_log off;
        }
        
        #location / {
        #    root   /usr/local/www/nginx;
        #    index  index.html index.htm;
        #}
        
        #error_page  404              /404.html;
        
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        location ~ \.php$ {
            proxy_pass   http://127.0.0.1:8989;
            include /usr/local/etc/nginx/proxy.conf;
        }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

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

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

 #    location / {

    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;

    #        index  index.html index.htm;

    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
        include /usr/local/etc/nginx/vhost/*;

}


Spoiler! :

konfigurasi proxy.conf
Letakkan di /usr/local/etc/nginx/proxy.conf
Code:
proxy_buffering         on;

proxy_redirect          off;
proxy_set_header        Host            $host;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forward-For   $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   90;
proxy_send_timeout      90;
proxy_read_timeout      90;
proxy_buffers           100 8k;


Spoiler! :

konfigurasi VHost :p
Code:
server {

    listen ip-server:80;
    server_name blabla;

    error_log  /var/log/nginx/blabla-error.log;
    access_log /var/log/nginx/blabla-access.log main;

    location / {
        proxy_pass http://127.0.0.1:8989;
        include /usr/local/etc/nginx/proxy.conf;
    }
}



Dan semua sudah selesai, Maaf jika ada yang salah :p, semoga thread ini bermanfaat bagi anda .. 



Ada yg lupa hehehehe jika ingin cek jalan tidaknya konfigurasi anda .. coba pake ini

Spoiler! :

Cek Nginx berjalan atau tidak
Code:
# curl -I ip-vps

Hasilnya akan seperti ini
Code:
HTTP/1.1 200 OK
Server: nginx/versi
Date: Tue, 16 Jun 2015 11:44:25 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/Versi

Cek Apache Berjalan Atau Tidak
Code:
# curl -I ip-vps:8989

Hasilnya
Code:
HTTP/1.1 200 OK

Server: apache/versi (FreeBSD) PHP/Versi
Date: Tue, 16 Jun 2015 11:44:25 GMT
Content-Type: text/html; charset=UTF-8
X-Powered-By: PHP/Versi




RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - abdilahrf - 06-13-2015

Coming sooooon...........


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - Kresna - 06-13-2015

Kamprettt ane udh nungguin padahal -_____- -5 buat ente :v


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - jufianto - 06-13-2015

spoilernya buat ane jantungan -_____-


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - Axozie - 06-13-2015

wihhhh keren nih Big Grin


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - go_block - 06-14-2015

Jhahahahaaa ,om ino'ot bisa ajaaa , Smile


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - agoes riyanto - 06-14-2015

kaya gaktau tingkah inot aja..


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - Creed - 06-14-2015

Yeayy coming soon ane kena trap spoiler Sad


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - go_block - 06-15-2015

(06-13-2015, 08:43 PM)ino_ot Wrote: hehehe, lumayan yang kena trap dari thread ini, Maaf ya soalnya koneksi internet dirumah lagi kacau, Makanya ane kasih coming soon dulu. 

Baik di postingan kali ini ane membagi sebuah teknik or trik dari 2 buah web server yang tidak aneh lagi di telinga temen - temen IBTeam. Udah berkeliaran banyak sih di google, tapi alangkah baiknya jika ane ringkas disini, hehehe semoga tidak repost yang mas momod.

Baik Sesuai dengan judul ane pengen ngasih sedikit trik agar dua webserver ini bisa berjalan dalam 1 server dengan memakai fungsi dan keunggulan dari masing - masing webserver tersebut.

Nginx As a Reverse Proxy For Apache on FreeBSD 10.1

Baik Sebagai pembukaan silakan cek Thread ini, Untuk kelebihan Masing - masing webser

https://indonesianbacktrack.or.id/forum/thread-5734.html?highlight=nginx

Nah setelah baca itu, silakan simak baik - baik cara konfigurasinya hehehe
Satu  lagi, ada beberapa yang bilang agar tidak bisa di attack dengan slowrolis

Spoiler! :

Update Portsnap

Code:
# portsnap extract
# portsnap fetch update


Spoiler! :


Install Apache

Code:
# pkg install apache24

Enable apache sebagai service tambahkan "apache24_enable=YES" di /etc/rc.conf, tapi kita menggunakan sysrc seperti dibawah ini.

Code:
# sysrc apache24_enable=YES

Jalankan Apache24

Code:
# service apache start



Spoiler! :

Install Mysql Versi Terbaru -. Mysql 5.6

Code:
# pkg install mysql56-server

Enable Mysql Service

Code:
# sysrc mysql_enable=YES

Jalankan Mysql Server

Code:
# service mysql-server start

Berikan Password untuk login user mysql

Code:
# mysql_secure_installation
Silakan baca baik2 yang ada di dialog mysql nantinya =)



Spoiler! :

Install PHP Versi Terbaru -> php 5.6

Code:
# pkg install mod_php56 php56-mysql php56-mysqli

Copy php.ini

Code:
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Jalankan Rehash untuk mengenerate cache sistem

Code:
rehash

Konfigurasi apache agar bisa membaca file .php


Code:
# nano /usr/local/etc/apache24/httpd.conf
[code]

Cari Line Directory Index, dan tambahan index.php di line tersebut, contoh :
[code]
DirectoryIndex index.php index.html index.htm
[code]

Tambahkan ini di baris terakhir file, agar apache bisa membaca file php dari php processor
[code]<FilesMatch "\.php$">
   SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
   SetHandler application/x-httpd-php-source
</FilesMatch>


[/code]
[/code][/code]

Coba dulu om ino'ot, Smile
Test"
Jhehehehe


RE: Nginx as a Reverse Proxy for Apache on FreeBSD 10.1 - itnewbie19 - 06-15-2015

weee...
minta ijin buat praktek om Big Grin