02 January , 2019

Force Redirect HTTP ke HTTPS di NGINX web server

Force Redirect HTTP ke HTTPS di apache mungkin sudah biasa kita dengar dan kita baca. cukup dengan menggunakan .htaccess semua beres. Lantas, bagaimana cara force redirect http ke https di nginx ?

Edit virtual host nginx anda. jika menggunakan vestacp, lokasi file ada di /home/username/conf/web/nginx.conf atau jika menggunakan LEMP ubuntu ada di /etc/nginx/sites-enabled/namahost.conf dan gunakan code berikut:

server {
    listen      80;
    server_name domainanda.com;
    return 301 https://$server_name$request_uri;
}

atau untuk nginx versi 0.9.1 bisa dengan code berikut:

server {
    listen      80;
    server_name domainanda.com;
    rewrite     ^ https://$server_name$request_uri? permanent;

}

Oke sekian dulu artikel dari saya semoga membantu kawan-kawan semua.

Share

Nurul Hidayat

Hello, saya adalah seorang software developer khususnya dibidang web. saya sangat menyukai Shell Scripting & Security semoga tulisan-tulisan kecil saya bisa bermanfaat.

You may also like...

31,686 Responses

  1. Excellent blog you’ve got here.. It’s hard to find excellent writing
    like yours these days. I honestly appreciate people like you!
    Take care!!

  2. Great blog you’ve got here.. It’s difficult to find excellent writing like yours nowadays.
    I really appreciate people like you! Take care!!

  3. Fantastic beat ! I would like to apprentice while you
    amend your site, how can i subscribe for a blog website?
    The account helped me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast offered bright
    clear idea

  4. Hi! I just would like to give you a big thumbs up for the excellent information you have got right here on this post.
    I will be coming back to your blog for more soon.

  5. 카지노 says:

    Your method of telling the whole thing in this post is in fact
    fastidious, every one be capable of simply understand it,
    Thanks a lot.

Leave a Reply