D
D
Dmitry Tarasov2021-12-14 21:22:07
Nginx
Dmitry Tarasov, 2021-12-14 21:22:07

How to force curl to redirect request directly to nginx?

I want to make it so that when accessing a host (for example, site.com) via curl inside the server, the request immediately goes to nginx, for the test I do curl site.com --resolve site. com:80:127.0.0.1 but just a response comes from nginx

Welcome to nginx!


nginx conf for site.com

server {
  server_name site.com www.site.com;
  charset UTF-8;
  index 404.html;
  disable_symlinks if_not_owner from=$root_path;
  include /etc/nginx/vhosts-includes/*.conf;
  include /etc/nginx/vhosts-resources/site.com/*.conf;
  access_log /var/www/httpd-logs/site.com.access.log;
  error_log /var/www/httpd-logs/site.com.error.log notice;
  ssi on;
  set $root_path /var/www/site/data/www/site.com;
  root $root_path;
  listen 80;
  listen 443 ssl http2;
  error_page 403 400 404 = http://site.com/404.html;
#	return  301 http://$server_name$request_uri;


       if ($scheme = https) {
            rewrite ^ http://$server_name$request_uri? permanent;
       }


    if ($request_method !~ ^(GET|HEAD|POST)$ ) {
      return 444;
    }

    if ( $http_user_agent ~* (LWP::Simple|BBBike|XSpider|OpenVas|Zeus|DirBuster|acunetix|BTWebClient|nmap|nikto|wikto|sf|sqlmap|bsqlbf|w3af|acunetix|havij|appscan|WordPress) ) {
      return 403;
    }

    location / {
      if (!-e $request_filename){
        rewrite ^(.*)$ /$1.php;
      }
    }

    if ($request_uri ~ "\.php") {
      rewrite ^/(.+)\.php$ /$1 permanent;
    }

    #limit_conn perserver 260;

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|js|css|txt|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar)$ {
      access_log off;
      expires 7d;
      break;
    }

    location ~ \.(php)$ {
  #limit_req zone=one burst=35;
  fastcgi_index index.php;
  fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
  try_files $uri =404;
  include fastcgi_params;
    }

    location = /status-phpfpm {
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME /status-phpfpm;
  fastcgi_pass 127.0.0.1:9000;
  access_log off;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-12-14
@fast-je

server_name localhost;replace with server_name site.com;
PS
How nginx processes requests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question