Several Nginx reverse proxy configuration templates

As more and more network services, plus a variety of IP port address can not remember, so do repercussions agency with Nginx, can also be good addresses within the distribution network management.

Here are several Nginx configuration templates. But also because their own way of configuration, the wrong place, please correct me, thank you first.

 

# Reload Configuration

nginx -s reload

 

# Php configuration

server {
        listen 88;
        server_name _;

        location ^~ /myphp{
                alias /www/myphp;
                index   index.php index.html index.htm;
                if (!-e $request_filename) {
                        rewrite ^/myphp/(.*)$ /index.php/$1 last;
                }
                location ~ \.php(/|$) {
                        fastcgi_split_path_info ^(.+\.php)(/.*)$;
                        fastcgi_index  index.php;
                        include fastcgi.conf;
                        fastcgi_param SCRIPT_FILENAME $request_filename;
                        fastcgi_pass 127.0.0.1:9000;
                }

   }
}

 

# 1 Reverse Proxy

# Http header need to pass parameters

 location ~ ^/api/(.*)$ {
        proxy_pass http://127.0.0.1:8080/$1;
        proxy_redirect     off;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }

 

Reverse proxy # 2
# request /xxx/a.html, points to http: // localhost: 82 / a.html

location /xxx {
         proxy_pass  http://localhost:82/;
         index  index.html index.htm index.jsp;
    }

 

Reverse proxy # 3
# request /xxx/a.html, points to http: // localhost: 82 / xxx / a.html

location /xxx {
         proxy_pass  http://localhost:82;
         index  index.html index.htm index.jsp;
    }

 

# Static web server1

# Request /wiki/xxx.html, points to the /data/work/gitbook/_book/xxx.html

location /wiki {
         alias  /data/work/gitbook/_book/;
         index  index.html index.htm index.jsp;
    }

 

# Server2 static Web
# request /wiki/xxx.html, points to the /data/work/gitbook/_book/wiki/xxx.html

location /wiki {
         root /data/work/gitbook/_book/;
         index  index.html index.htm index.jsp;
    }

 

#Nginx build a file server download

server {
        listen       8090;
        server_name  _;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        keepalive_timeout  60;
        tcp_nodelay on;
        server_tokens       off;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers  on;


        location / {
        alias /data/work/www/download;
        }
        charset utf-8;
}

 

Guess you like

Origin www.cnblogs.com/mrblue/p/12166717.html