Saturday, May 28, 2022

Nginx Setup

 

1. yum install yum-utils 

2. yum-config-manager --add  https://openresty.org/package/centos/openresty.repo 

3. yum install openresty /usr/local/openresty/nginx 

4. cd  /usr/local/openresty/nginx/conf 

5. Add the proxy settings as per needs 

5. Edit nginx.conf to update the ip of the server in "proxy redirect" sections .For example, current server ip is 18.32.76.34.

6. Remove nginx.conf.default  

7. cd /usr/local/openresty/nginx/sbin  

8. nginx -p /usr/local/openresty/nginx/ -c conf/nginx.conf 

9. pkill -9 docker  



#user  nobody;

worker_processes  8;

worker_rlimit_nofile 100000;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logs/nginx.pid;

pid    /var/run/nginx.pid;

 

 

events {

    worker_connections 100000;

    use epoll;

    multi_accept on;

 

}

 

 

http {

    include       mime.types;

    default_type  application/octet-stream;

     ################# Gzip Settings ################

    gzip on;

    gzip_comp_level 4;

    gzip_min_length 1024;

    gzip_proxied any;

    gzip_static on;

    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js application/soap+xml;

    gzip_disable "MSIE [1-6]\.";

map $http_x_forwarded_proto $http_scheme

{ ~https https; default http; }

 

 

 

        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                  '$status $body_bytes_sent '

                  'X-Auth-Token: "$sent_http_x_auth_token"';

 

 

 

 

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

 

    #access_log  logs/access.log  main;

 

    sendfile        on;

    tcp_nopush     on;

    tcp_nodelay        on;

    keepalive_timeout  30;

    keepalive_requests 10000;

    reset_timedout_connection on;

    client_body_timeout 30;

    send_timeout 300;

    #gzip  on;

 

    server {

        listen       80;

        server_name  localhost;

        access_log  /usr/local/openresty/nginx/logs/frontend.log ;

        error_log   /usr/local/openresty/nginx/logs/error.log;

 

        #charset koi8-r;

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root   html;

            index  index.html index.htm;

        }

 

        #error_page  404              /404.html;

 

        # redirect server error pages to the static page /50x.html

        #

         error_page   500 502 503 504  /50x.html;

        underscores_in_headers on;

 

        location = /50x.html {

            root   html;

 

        }

 

############################Redirection Logic For Comp1######

 

location /comp1/ {

 # proxy_redirect  http://12.89.29.40/comp1/api/v2.0/search/;

 #   proxy_read_timeout 60s;

      real_ip_header      X-Forwarded-For;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

          proxy_set_header X-Forwarded-Proto $http_scheme;

           proxy_set_header  X-Real-IP $remote_addr;

                add_header  Access-Control-Allow-Origin *;

 proxy_pass      http://12.89.29.40:9023$request_uri;

 #                      ################# Gzip Settings ################

           gzip  on;

           gzip_comp_level 4;

           gzip_min_length 10240;

           gzip_proxied expired no-cache no-store private auth;

           gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js application/soap+xml;

           gzip_disable "MSIE [1-6]\.";

 

             }  

   

}


No comments:

Post a Comment

Popular Posts

Most Featured Post

GitHub: Squash all commits in PR

  Command Meaning git fetch origin Get the latest origin/master . git reset --soft origin/master Move your branch to match origin/master , b...