Linux technical support - support@alexlinux.com


nginx

# REDIRECT
server {
    listen 80;
    server_name www.alexlinux.com;
    return 301 https://$host$request_uri;
}

# ADD CERTIFICATE AND KEY
server {
    listen   443;
    ssl    on;
    ssl_certificate        /etc/nginx/pki/chain.crt;
    ssl_certificate_key    /etc/nginx/pki/www.alexlinux.com.key;
    server_name www.alexlinux.com;
    location / {
        root   /usr/share/nginx/html;
        index  index.html;
    }
}

# TCP BALANCER
stream {
    upstream pop3 {
        server host004.tts.loc:110;
        server host005.tts.loc:110;
        server host006.tts.loc:110;
    }

    server {
        listen 110;
        proxy_pass pop3;
    }
}

# REDIRECT TO DOCKER CONTAINER
server {
  listen       80;
  server_name  alexlinux.com;
  root         /usr/share/nginx/html;
  index        index.php;
  location / {
    proxy_pass http://127.0.0.1:4444;
    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_set_header X-Forwarded-Proto $scheme;
  }
}
# /prices -> /index.php?_url=/prices
rewrite ^(.*)$ /index.php?_url=$1;
# CUT FROM URI

https://alexlinux.com/foo/login/success?token=123

->

https://alexlinux.com/login/success?token=123

location ^~ /foo {
    rewrite ^/foo(.*)$ $1 permanent;
}
# REMOVE PREFIX FROM LOCATION
curl https://www.alexlinux.com/s3/agorbachev/agorbachev.txt
->
curl https://www.alexlinux.com/agorbachev/agorbachev.txt

rewrite ^/s3(.*)$ $1 break;
# https://github.com/garakh/kladrapi
location / {
    if (!-e $request_filename){
    rewrite ^(.*)$ /index.php?_url=$1;
    }
}

location ~ \.php$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index /index.php;

    include fastcgi_params;
    fastcgi_split_path_info       ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
proxy_set_header    X-Request-alexlinux   $http_x_request_alexlinux;
#
    location /bitrix {
      set $proxy_pool "http://master";
      if ($http_x_request_alexlinux = "alex"){
          set $proxy_pool "http://someserver";
      }
      proxy_pass $proxy_pool;
    }
#block city with custom page
vhost
    if ($not_allowed_region = no) {
        rewrite ^(.*)$ /50x.html break;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/50x;
    }
nginx.conf
    map $geoip_city $not_allowed_region {
        default yes;
        Moscow no;
    }

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>