nginx problem accessing virtual hosts

Sc0rian

Verified User
Joined
Jul 26, 2009
Messages
18
Hello all,

I have nginx running on port 81. I can access all my sites (including virtual ips) on the port 81. However when I forward the traffic from port 80 to 81, the virtual ips have a message saying "Apache is running normally". However I still can access the sites on the port.

All server ip traffic is fine.

source:
http://www.bxtra.net/comment/3642
 
Hello,

I've got experience with building front-end & back-end architecture with Nginx and Apache. And I can sure fix it very quickly if you give me root access to your server. Of course it will cost you some money. If you have time to discuss it here on the forums, you need to show your real nginx config with real IPs (you might want to hide some digits there), and other data. Just PM for a quote or post here requested config and results of

Code:
ps aux | egrep "apache|nginx"

and

Code:
netstat -an | grep LISTEN | egrep ":80|:81"
 
thanks for the reply and offering your services. I'd rather learn and fix it myself :)


[root@~]# netstat -an | grep LISTEN | egrep ":80|:81"
tcp 0 0 <virtual ip>:81 0.0.0.0:* LISTEN
tcp 0 0 <virtual ip>:81 0.0.0.0:* LISTEN
tcp 0 0 <serverip>:81 0.0.0.0:* LISTEN
tcp 0 0 :::80 :::* LISTEN

apache 24090 0.6 1.3 29252 13612 ? S 18:34 0:00 /usr/sbin/httpd -k start -DSSL
apache 24092 0.9 2.1 39584 22056 ? S 18:34 0:00 /usr/sbin/httpd -k start -DSSL
apache 24096 0.2 1.9 35892 20256 ? S 18:34 0:00 /usr/sbin/httpd -k start -DSSL
apache 24120 0.3 1.7 35752 17840 ? S 18:34 0:00 /usr/sbin/httpd -k start -DSSL
apache 24495 0.0 1.4 30892 14756 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24496 1.0 2.1 39892 22164 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24516 1.5 3.6 55496 38040 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24519 0.1 1.2 28996 13224 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24521 2.7 4.0 58244 41984 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24522 0.0 1.2 29124 12672 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24524 0.0 1.1 28740 12364 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24535 1.1 1.7 36008 17876 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24536 0.0 1.1 28592 12084 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24537 0.0 1.1 28592 12112 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24539 0.0 0.0 0 0 ? Z 18:35 0:00 [httpd] <defunct>
apache 24540 0.0 1.1 28592 11540 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
apache 24541 0.0 1.1 28592 11548 ? S 18:35 0:00 /usr/sbin/httpd -k start -DSSL
root 24548 0.0 0.0 4132 752 pts/0 R+ 18:35 0:00 egrep apache|nginx
root 28238 0.0 0.0 19576 284 ? Ss May29 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
apache 28239 0.0 0.0 19888 804 ? S May29 0:00 nginx: worker process
apache 28240 0.0 0.0 19888 548 ? S May29 0:00 nginx: worker process
apache 28241 0.0 0.0 19736 484 ? S May29 0:00 nginx: cache manager process
 
You need to show your real nginx config with real IPs (you might want to hide some digits there)

Code:
cat /usr/local/nginx/conf/nginx.conf
 
Code:
 cat /usr/local/nginx/conf/nginx.conf
user  apache apache;

worker_processes     2; # Set it according to what your CPU have. 4 Cores = 4
worker_rlimit_nofile 8192;

pid /var/run/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"';

    server_tokens off;
    access_log  /var/log/nginx_access.log  main;
    error_log  /var/log/nginx_error.log debug;


    server_names_hash_bucket_size 64;
    sendfile on;
    tcp_nopush     on;
    tcp_nodelay    off;
    keepalive_timeout  30;
    gzip  on;
    gzip_comp_level 9;
    gzip_proxied any;

    proxy_buffering on;
    proxy_cache_path /usr/local/nginx/proxy_temp levels=1:2 keys_zone=one:15m inactive=7d max_size=1000m;
    proxy_buffer_size 16k;
    proxy_buffers 100 8k;
    proxy_connect_timeout      60;
    proxy_send_timeout         60;
    proxy_read_timeout         60;

    server {
      listen <server ip>:81 default rcvbuf=8192 sndbuf=16384 backlog=32000; # Real IP here
      server_name <server host name> _;     # "_" is for handle all hosts that are not described by server_name
      charset off;
      access_log  /var/log/nginx_host_general.access.log  main;
      location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://<server ip>;    # Real IP here
        client_max_body_size       16m;
        client_body_buffer_size    128k;
        proxy_buffering     on;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         120;
        proxy_buffer_size          16k;
        proxy_buffers              32 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
      }
  location /nginx_status {
               stub_status on;
               access_log   off;
               allow 127.0.0.1;
               deny all;
       }
    }
    # below is include so that you can have separate setting per vhost.
    include /usr/local/nginx/vhosts/*.conf;

}


Code:
# cat /usr/local/nginx/vhosts/1.conf
   server {
      listen <virt ip>:81 default rcvbuf=8192 sndbuf=16384 backlog=32000; # Real IP here
      server_name <virt domain name>.com ;     # "_" is for handle all hosts that are not described by server_name
      charset off;
      access_log  /var/log/nginx_host_general.access.log  main;
      location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://<virt ip>;    # Real IP here
        client_max_body_size       16m;
        client_body_buffer_size    128k;
        proxy_buffering     on;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         120;
        proxy_buffer_size          16k;
        proxy_buffers              32 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;

      }
}
 
I don't see what can cause such a behavior in your case, and don't have time to go through the guide a link to which you gave. Note though I use NGINX with Apache... my configuration differs, and I don't use firewall to forward requests from Apache to NGINX (I used to do so many years ago on FreeBSD). So you should either refer the question to the author of the guide, or wait for somebody's else answer here.

Note, I still can find time and fix you issue in terms of a commerce service.
 
Back
Top