Want more timely Centmin Mod News Updates?
Become a Member

Sysadmin reverse proxy nginx and centmin mod

Discussion in 'System Administration' started by marc3000, Jan 14, 2018.

  1. marc3000

    marc3000 New Member

    26
    8
    3
    Feb 2, 2017
    Ratings:
    +13
    Local Time:
    12:05 PM
    I am having a problem, im not sure if it is centmin mod, but i think it might be

    i have 2 websites on 1 server, both websites are on different server operating systems, all virtual machines

    ---physical server virtualization
    --vm1 - reverse proxy nginx
    --vm2 - centos+centmin mod(website1)
    --vm3 - centos+webmin(website2)


    what is supposed to happen is, the nginx server is supposed to direct the domain to the correct virtual machine

    but it's not happening. the first website works fine, but the second website, all i see is the "Centmin Mod Nginx Test Page"


    i can't figure out why,
    so, i tried this setup,
    *webmin is just some centos backend server gui,

    ---physical server virtualization
    --vm1 - reverse proxy nginx
    --vm2 - centos+webmin(website1)
    --vm3 - centos+webmin(website2)


    and this works fine, i can easily access both websites, for some reason with centmin mod, i can't get it working,


    would you happen to have any idea?


    here is my nginx.conf file

    Code:
    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        server {
           listen 80;
           server_name server.website1.com;
           location / {
                proxy_set_header    x-real-IP          $remote_addr;
                proxy_set_header    x-forwarded-for    $proxy_add_x_forwarded_for;
                proxy_set_header    host               $host;
                proxy_pass          http://10.0.2.4;   
           }
          }
    
        server {
           listen 80;
           server_name server.website2.com;
           location / {
                proxy_set_header    x-real-IP          $remote_addr;
                proxy_set_header    x-forwarded-for    $proxy_add_x_forwarded_for;
                proxy_set_header    host               $host;
                proxy_pass          http://10.0.2.5;   
           }
          }
    
    }
    

     
  2. eva2000

    eva2000 Administrator Staff Member

    32,303
    7,172
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,906
    Local Time:
    3:05 AM
    Nginx 1.13.x
    MariaDB 5.5
    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such custom reverse proxy setups.

    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)

    With that said, for Centmin Mod you shouldn't add web sites into nginx.conf itself. Is the server.website1.com and server.website2.com the actual main hostnames or separate sites form main hostnames ?

    What does your /usr/local/nginx/conf/conf.d/virtual.conf and /usr/local/nginx/conf/conf.d/yourdomain.com.conf contents look like ? Make sure virtual.conf main hostname's server_name isn't same as any added nginx vhost site's domain name as per Getting Started Guide step 1, the main hostname needs to be unique.

    You can check via recursive grep filter of your domain name in vhost directory at /usr/local/nginx/conf/conf.d
    Code (Text):
    grep -rnw 'yourdomain.com' /usr/local/nginx/conf/conf.d
    

    Also check DNS is correct use dig to check DNS for domain
    Code (Text):
    dig +short A @8.8.8.8 yourdomain.com
    dig +short A @8.8.8.8 www.yourdomain.com
    dig +short A @8.8.8.8 hostname.yourdomain.com
    

    check HTTP headers via curl for both HTTP (and HTTPS if you have HTTPS/SSL)
    Code (Text):
    curl -I http://yourdomain.com
    curl -I http://www.yourdomain.com
    curl -I https://yourdomain.com
    curl -I https://www.yourdomain.com
    curl -I http://hostname.yourdomain.com