A
A
Andrey Bystrov2016-01-15 10:18:59
JavaScript
Andrey Bystrov, 2016-01-15 10:18:59

How to make Nginx process ajax requests?

At 10.33.241.2:8098, there is an html page on the internal network that calls two ajax scripts - ajax_auth_reg.php and ajax_auth_sms.php, but nginx cannot process them. Logs are empty. Tell me how to make him work them out? I suspect that the wrong config.

user  nginx;
#user root;
worker_processes  10;
worker_rlimit_nofile 100000;

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

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
    use epoll;
}


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

    log_format  main  '$remote_addr - [$time_local] $status "$request"'
                      ' $body_bytes_sent'
                      ' "$http_user_agent"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    server_tokens   off;
    gzip            on;
    gzip_static     on;
    gzip_comp_level 5;
    gzip_min_length 1024;
    keepalive_timeout  65;
#    limit_zone   myzone  $binary_remote_addr  10m;

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;

    server {
#        limit_conn   myzone  10;
        listen       *:80;

        charset utf8;

        access_log  /data/home/mart/logs/access.mart.ru.access.log  main;
  root /data/home/mart/www/access.mart.ru;
        location / {
    	    if ($uri ~ \/redirect\.php$) {
    		break;
    	    } 
    	    if ($server_addr = 10.32.255.14) {
        rewrite ^(.*)$ /redirect.php last;
    	    }    	    
        }


        error_page  404              /404.html;

        location = /404.html {
            root   /usr/share/nginx/html;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location = /denied/ {
    	    index index.php;
    	    if ($uri ~ blok\.gif$) {
    		break;
    	    } 
        }

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

    }

    # IPOE Block servers
    server {
  listen       10.40.64.100:8000;
  listen       10.40.64.100:8001;
  listen       10.40.64.100:8002;
  listen       10.40.64.100:8003;
  listen       10.40.64.100:8004;
  listen       10.40.64.100:8005;
  listen       10.40.64.100:8006;
  listen       10.40.64.100:8007;
  listen       10.40.64.100:8008;
  listen       10.40.64.100:8009;
  listen       10.40.64.100:8010;
  listen       10.40.64.100:8011;
  listen       10.40.64.100:8012;
  listen       10.40.64.100:8013;
  listen       10.40.64.100:8014;
  listen       10.40.64.100:8015;
  listen       10.40.64.100:8016;
  listen       10.40.64.100:8017;
  listen       10.40.64.100:8018;
  listen       10.40.64.100:8019;
  listen       10.40.64.100:8020;
  listen       10.40.64.100:8021;
#	listen       10.40.64.100:8022;
  listen       10.40.64.100:8023;
  listen       10.40.64.100:8024;
  listen       10.40.64.100:8025;
  listen       10.40.64.100:8026;
  listen       10.40.64.100:8027;
  listen       10.40.64.100:8028;
  listen       10.40.64.100:8029;
  listen       10.40.64.100:8030;
  listen       10.33.241.2:8099;
  root /data/home/mart/www/redirect;
        access_log  /data/home/mart/logs/redirect.mart.ru.access.log  main;
        error_log  /data/home/mart/logs/redirect.mart.ru.error.log;
        location / {
            index  index.php;
            expires 1m;
        }


 location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /$document_root/$fastcgi_script_name;
            include        fastcgi_params;
        }
}
#######START############TEST Для Страницы авторизации
   server {
  charset UTF-8; 
  listen       10.40.64.100:8022;
  listen       <b>10.33.241.2:8098</b>;
  root	/data/home/mart/www/redirect/wifi;
        access_log  /data/home/mart/www/redirect/wifi/wifi.access.log;
        error_log  /data/home/mart/www/redirect/wifi/wifi.error.log;

  location / {
      try_files $uri $uri/ /index.php?request=$uri&$args;
            index  index.php;
            expires 100d;
        }

        location /data/home/mart/www/redirect/wifi/ajax/ajax_auth_reg.php {
            allow all;
        }
        location /data/home/mart/www/redirect/wifi/ajax/ajax_auth_sms.php {
            allow all;
        }

        # if (!-e $request_filename)
        #     {
        #        rewrite ^/(.*)$ /index.php?q=$1 last;
        #      }

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

    }

##############END###############################

    # 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;
    #    server_name  localhost;

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

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-01-16
@prolis

Try instead

listen       10.33.241.2:8098;
listen       10.33.241.2:8098 default_server;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question