[Tanya] Nginx reverse proxy config

Discussion in 'Dedicated Server dan Colocation' started by rizkyprogrammer, 21 Sep 2016.

Thread Status:
Not open for further replies.
  1. rizkyprogrammer

    rizkyprogrammer Beginner 2.0

    Messages:
    20
    Likes Received:
    3
    Trophy Points:
    3
    Saya ingin membuat reverse proxy, jadi ketika akses http://domain.com:10000 akan di truskan https://192.168.7.23:10000 berikut adalah config saya :

    server {
    listen 10000;
    server_name domain.com;
    location / {
    proxy_pass https://192.168.7.23:10000;
    proxy_redirect http://domain.com:10000 https://192.168.7.23:10000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    }

    namun setelah saya restart muncul error
    # systemctl restart nginx
    Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.


    Pertanyaan saya kira-kira apa ya yang salah dengan config saya tersebut,,

    Terima kasih sebelumnya
     
  2. masiqbal

    masiqbal Expert 2.0

    Messages:
    863
    Likes Received:
    249
    Trophy Points:
    43
    coba proxy_redirect nya diilangin hasilnya gimana
     
  3. rizkyprogrammer

    rizkyprogrammer Beginner 2.0

    Messages:
    20
    Likes Received:
    3
    Trophy Points:
    3
    Terimakasih atas responnya @masiqbal

    untuk resultnya masih tetap sama mas,,
    # systemctl restart nginx
    Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
     
  4. masiqbal

    masiqbal Expert 2.0

    Messages:
    863
    Likes Received:
    249
    Trophy Points:
    43
    coba cari clue di /var/log
    itu tadi seluruh isi nginx.conf atau di file apa?

    kalau perintah "nginx -t" (atau mungkin harus full path coba cari dimana) hasilnya apa? Ini untuk ngetest file config bener apa enggak.
     
    rizkyprogrammer likes this.
  5. hendranata

    hendranata Hosting Guru

    Messages:
    1,112
    Likes Received:
    85
    Trophy Points:
    48
    Jalankan systemctlstatus nginx.service kan kelihatan itu error nya apa
     
    rizkyprogrammer likes this.
  6. rizkyprogrammer

    rizkyprogrammer Beginner 2.0

    Messages:
    20
    Likes Received:
    3
    Trophy Points:
    3
    Terima kasih atas responnya mas @hendranata

    outputnya seperti berikut :
    # systemctl status nginx.service
    ‚óŹ nginx.service - The nginx HTTP and reverse proxy server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Rab 2016-09-21 11:58:21 WIB; 1h 57min ago
    Process: 6755 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
    Process: 8089 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
    Process: 8086 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
    Main PID: 6756 (code=exited, status=0/SUCCESS)

    Sep 21 11:58:21 urbanlifestore.com systemd[1]: Starting The nginx HTTP and reverse proxy server...
    Sep 21 11:58:21 urbanlifestore.com nginx[8089]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    Sep 21 11:58:21 urbanlifestore.com nginx[8089]: nginx: [emerg] bind() to 0.0.0.0:10000 failed (13: Permission denied)
    Sep 21 11:58:21 urbanlifestore.com nginx[8089]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Sep 21 11:58:21 urbanlifestore.com systemd[1]: nginx.service: control process exited, code=exited status=1
    Sep 21 11:58:21 urbanlifestore.com systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
    Sep 21 11:58:21 urbanlifestore.com systemd[1]: Unit nginx.service entered failed state.
    Sep 21 11:58:21 urbanlifestore.com systemd[1]: nginx.service failed.


    Outpur dari /var/log/nginx/error.log
    2016/09/21 11:31:46 [emerg] 7090#0: bind() to 0.0.0.0:10000 failed (13: Permission denied)
    2016/09/21 11:57:57 [emerg] 8048#0: bind() to 0.0.0.0:10000 failed (13: Permission denied)
    2016/09/21 11:58:21 [emerg] 8089#0: bind() to 0.0.0.0:10000 failed (13: Permission denied)
     
  7. rizkyprogrammer

    rizkyprogrammer Beginner 2.0

    Messages:
    20
    Likes Received:
    3
    Trophy Points:
    3
    output dari # nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
     
  8. masiqbal

    masiqbal Expert 2.0

    Messages:
    863
    Likes Received:
    249
    Trophy Points:
    43
    Ini pakai centos/rhel 7 ya?
    Coba tambahkan port 10000 dengan semanage

    semanage port -a -t http_port_t -p tcp 10000

    Jangan lupa juga buka port 10000 di firewall
     
    rizkyprogrammer likes this.
  9. rizkyprogrammer

    rizkyprogrammer Beginner 2.0

    Messages:
    20
    Likes Received:
    3
    Trophy Points:
    3
    terimakasih @masiqbal sdah work untuk akses ke port 10000

    namun skarang ada lagi trouble mas, ketika saya login di port 10000 (virtualmin)
    muncul pesan sebagai berikut :

    Error - No cookies
    Your browser does not support cookies, which are required for this web server to work in session authentication mode

    Apakah ada yang kurang ya diconfig saya tadi?
     
  10. masiqbal

    masiqbal Expert 2.0

    Messages:
    863
    Likes Received:
    249
    Trophy Points:
    43
    Bentar bentar, ini maksudnya doamin.com:10000 itu tadi mau diarahkan ke https://192.168.7.23:10000 yg merupakan virtualmin?

    Coba tambahkan berikut di config nginx:
    proxy_cookie_domain 192.168.7.23 domain.com;
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...