• nginx反向代理配置


      1 #user  nobody;
      2 worker_processes  1;
      3 
      4 error_log  logs/error.log;
      5 error_log  logs/error.log  notice;
      6 error_log  logs/error.log  info;
      7 
      8 #pid        logs/nginx.pid;
      9 
     10 
     11 events {
     12     worker_connections  1024;
     13 }
     14 
     15 
     16 http {
     17     include       mime.types;
     18     default_type  application/octet-stream;
     19 
     20     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
     21                       '$status $body_bytes_sent "$http_referer" '
     22                       '"$http_user_agent" "$http_x_forwarded_for"';
     23 
     24     #access_log  logs/access.log  main;
     25 
     26     sendfile        on;
     27     #tcp_nopush     on;
     28 
     29     #keepalive_timeout  0;
     30     keepalive_timeout  65;
     31 
     32     #gzip  on;
     33     
     34     gzip  on;
     35     gzip_http_version 1.0;
     36     gzip_types        text/plain
     37                       text/xml
     38                       text/css
     39                       application/xml
     40                       application/xhtml+xml
     41                       application/rss+xml
     42                       application/atom_xml
     43                       application/javascript
     44                       application/x-javascript;
     45     gzip_disable      "MSIE [1-6].";
     46     gzip_disable      "Mozilla/4";
     47     gzip_comp_level   6;
     48     gzip_proxied      any;
     49     gzip_vary         on;
     50     gzip_buffers      4 8k;       
     51     gzip_min_length   1000;
     52     
     53         resolver 8.8.8.8;
     54         ##cache##
     55         proxy_http_version 1.1;
     56       proxy_connect_timeout 5;
     57       proxy_read_timeout 60;
     58       proxy_send_timeout 5;
     59       proxy_buffer_size 16k;
     60       proxy_buffers 4 64k;
     61       proxy_busy_buffers_size 128k;
     62       proxy_temp_file_write_size 128k;
     63         proxy_temp_path temp/proxy_temp;
     64         proxy_cache_path cache/proxy_cache levels=1:2 keys_zone=cache_one:200m inactive=5m max_size=30g;
     65         ##cache end#
     66         include vhost.conf;
     67     #server {
     68         #listen       80;
     69         #server_name  localhost;
     70 
     71         #charset koi8-r;
     72 
     73         #access_log  logs/host.access.log  main;
     74 
     75         #location / {
     76          #   root   html;
     77           #  index  index.html index.htm;
     78         #}
     79 
     80         #error_page  404              /404.html;
     81 
     82         # redirect server error pages to the static page /50x.html
     83         #
     84         #error_page   500 502 503 504  /50x.html;
     85         #location = /50x.html {
     86          #   root   html;
     87         #}
     88 
     89         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
     90         #
     91         #location ~ .php$ {
     92         #    proxy_pass   http://127.0.0.1;
     93         #}
     94 
     95         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     96         #
     97         #location ~ .php$ {
     98         #    root           html;
     99         #    fastcgi_pass   127.0.0.1:9000;
    100         #    fastcgi_index  index.php;
    101         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    102         #    include        fastcgi_params;
    103         #}
    104 
    105         # deny access to .htaccess files, if Apache's document root
    106         # concurs with nginx's one
    107         #
    108         #location ~ /.ht {
    109         #    deny  all;
    110         #}
    111     #}
    112 
    113 
    114     # another virtual host using mix of IP-, name-, and port-based configuration
    115     #
    116     #server {
    117     #    listen       8000;
    118     #    listen       somename:8080;
    119     #    server_name  somename  alias  another.alias;
    120 
    121     #    location / {
    122     #        root   html;
    123     #        index  index.html index.htm;
    124     #    }
    125     #}
    126 
    127 
    128     # HTTPS server
    129     #
    130     #server {
    131     #    listen       443 ssl;
    132     #    server_name  localhost;
    133 
    134     #    ssl_certificate      cert.pem;
    135     #    ssl_certificate_key  cert.key;
    136 
    137     #    ssl_session_cache    shared:SSL:1m;
    138     #    ssl_session_timeout  5m;
    139 
    140     #    ssl_ciphers  HIGH:!aNULL:!MD5;
    141     #    ssl_prefer_server_ciphers  on;
    142 
    143     #    location / {
    144     #        root   html;
    145     #        index  index.html index.htm;
    146     #    }
    147     #}
    148 
    149 }
    vhost.conf:
     1 ## Basic reverse proxy server ##
     2 upstream appservers{
     3     server backenddomain:80;
     4 }
     5 ## Start weboffice ##
     6 server {
     7     listen 8880;
     8     server_name frontenddomain;
     9 
    10     access_log  logs/weboffice.access.log;
    11     error_log  logs/weboffice.error.log;
    12     root   html;
    13     index  index.html index.htm index.php login.html;
    14 
    15     ## send request back to appservers ##.*ext-all-release.js
    16         location ~* /{
    17             proxy_pass  http://appservers;
    18             proxy_redirect default;
    19             
    20         proxy_cache cache_one;
    21         proxy_cache_valid 200 302 304 1h;
    22         proxy_cache_valid 301 1d;
    23         proxy_cache_valid any 5m;
    24         expires 30d;
    25         
    26         set $ae "";
    27       if ($http_accept_encoding ~* gzip) {
    28           set $ae "gzip";
    29       }
    30 
    31       #proxy_no_cache        0;
    32       #proxy_cache_bypass    0;
    33   
    34       proxy_next_upstream   error timeout invalid_header http_500;
    35       proxy_cache_use_stale error updating;
    36   
    37       proxy_set_header      Host                $host;
    38       proxy_set_header      X-Real-IP           $remote_addr;
    39       proxy_set_header      X-Forwarded-Host    $host;
    40       proxy_set_header      X-Forwarded-Server  $host;
    41       proxy_set_header      X-Forwarded-For     $proxy_add_x_forwarded_for;
    42       proxy_set_header      Accept-Encoding     "none";
    43 
    44         }
    45     #location ~* / {
    46        #proxy_pass  http://appservers;
    47        #}
    48 }
     frontenddomain只支持域名,不支持ip
  • 相关阅读:
    python列表作为默认参数的问题
    python 强制停止线程
    cProfile 分析python运行时间
    python global全局变量 模块通信问题
    ajax请求数据get、post
    vue中加载three.js全景图
    vue中加载three.js的gltf模型
    vue-cli2.x与vue-cli3.x的搭建
    cesium加载gltf模型
    vue/cli3引入cesium
  • 原文地址:https://www.cnblogs.com/javaleon/p/4040969.html
Copyright © 2020-2023  润新知