gnocuil 发表于 2017-12-29 07:37:51

帮忙看看这个nginx反向代理配置对不对

本帖最后由 gnocuil 于 2017-12-29 12:21 编辑

系统内存是16GB的,现在的这个设置好像都不怎么占用内存,才用900m左右。。

[*]userwww www;
[*]worker_processes auto;
[*]error_log/www/wwwlogs/nginx_error.logcrit;
[*]pid      /www/server/nginx/logs/nginx.pid;
[*]worker_rlimit_nofile 51200;
[*]
[*]events
[*]    {
[*]      use epoll;
[*]      worker_connections 51200;
[*]      multi_accept on;
[*]    }
[*]
[*]http
[*]    {
[*]      include mime.types;
[*]      include proxy.conf;
[*]      default_typeapplication/octet-stream;
[*]
[*]      server_names_hash_bucket_size 512;
[*]      client_header_buffer_size 32k;
[*]      large_client_header_buffers 4 32k;
[*]      client_max_body_size 50m;
[*]
[*]      sendfile   on;
[*]      tcp_nopush on;
[*]
[*]      keepalive_timeout 60;
[*]
[*]      tcp_nodelay on;
[*]
[*]      fastcgi_connect_timeout 300;
[*]      fastcgi_send_timeout 300;
[*]      fastcgi_read_timeout 300;
[*]      fastcgi_buffer_size 64k;
[*]      fastcgi_buffers 4 64k;
[*]      fastcgi_busy_buffers_size 128k;
[*]      fastcgi_temp_file_write_size 256k;
[*]                fastcgi_intercept_errors on;
[*]
[*]      gzip on;
[*]      gzip_min_length1k;
[*]      gzip_buffers   4 16k;
[*]      gzip_http_version 1.1;
[*]      gzip_comp_level 2;
[*]      gzip_types   text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
[*]      gzip_vary on;
[*]      gzip_proxied   expired no-cache no-store private auth;
[*]      gzip_disable   "MSIE \.";
[*]
[*]      limit_conn_zone $binary_remote_addr zone=perip:10m;
[*]                limit_conn_zone $server_name zone=perserver:10m;
[*]
[*]      server_tokens off;
[*]      access_log off;
[*]
[*]server
[*]    {
[*]      listen 888;
[*]      server_name www.bt.cn;
[*]      index index.html index.htm index.php;
[*]      root/www/server/phpmyadmin;
[*]
[*]      #error_page   404   /404.html;
[*]      include enable-php.conf;
[*]
[*]      location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
[*]      {
[*]            expires      30d;
[*]      }
[*]
[*]      location ~ .*\.(js|css)?$
[*]      {
[*]            expires      12h;
[*]      }
[*]
[*]      location ~ /\.
[*]      {
[*]            deny all;
[*]      }
[*]
[*]      access_log/www/wwwlogs/access.log;
[*]    }
[*]include /www/server/panel/vhost/nginx/*.conf;
[*]}
[*]
[*]复制代码




[*]
[*]server
[*]{
[*]    listen 80;
[*]    server_name www.baidu.com;
[*]    index index.php index.html index.htm default.php default.htm default.html;
[*]    root /www/wwwroot/www.baidu.com;
[*]   
[*]    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
[*]    #error_page 404/404.html;
[*]    #SSL-END
[*]   
[*]    #ERROR-PAGE-START错误页配置,可以注释、删除或修改
[*]    error_page 404 /404.html;
[*]    error_page 502 /502.html;
[*]    #ERROR-PAGE-END
[*]   
[*]    #PHP-INFO-STARTPHP引用配置,可以注释或修改
[*]    #PROXY-START
[*]    location ~ /purge(/.*) {
[*]      proxy_cache_purge cache_one $host$request_uri$is_args$args;
[*]      #access_log/www/wwwlogs/www.baidu.com_purge_cache.log;
[*]    }
[*]    location /
[*]    {
[*]      proxy_pass http://www.baidu.com;
[*]      proxy_set_header Host $host;
[*]      proxy_set_header X-Forwarded-For $remote_addr;
[*]      proxy_cache cache_one;
[*]      proxy_cache_key $host$request_uri$is_args$args;
[*]      proxy_cache_valid 200 304 15m;
[*]      proxy_cache_valid 301 302 10m;
[*]      proxy_cache_valid any 1m;
[*]      add_header X-Cache $upstream_cache_status;
[*]      
[*]      expires 30m;
[*]    }
[*]   
[*]    location ~ .*\.(php|html)?$
[*]    {
[*]      proxy_set_header Host $host;
[*]      proxy_set_header X-Forwarded-For $remote_addr;
[*]      proxy_pass http://www.baidu.com;
[*]
[*]      expires 30m;
[*]      
[*]    }
[*]
[*]    location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|ico|swf|flv)?$
[*]    {
[*]      proxy_set_header Host $host;
[*]      proxy_set_header X-Forwarded-For $remote_addr;
[*]      proxy_pass http://www.baidu.com;
[*]
[*]      expires 30d;
[*]      
[*]    }
[*]    #PROXY-END
[*]
[*]      include enable-php-54.conf;
[*]    #PHP-INFO-END
[*]   
[*]    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
[*]    include /www/server/panel/vhost/rewrite/www.baidu.com.conf;
[*]    #REWRITE-END
[*]   
[*]    #禁止访问的文件或目录
[*]    location ~ ^/(\.user.ini|\.htaccess|\.git|\.project|LICENSE|README.md)
[*]    {
[*]      return 404;
[*]    }
[*]   
[*]    access_log/www/wwwlogs/www.baidu.com.log;
[*]}复制代码

lzyroot 发表于 2017-12-29 08:15:14

看不懂,大佬上

南琴浪 发表于 2017-12-29 08:25:31

我真的要被这些模板气疯了。都说了 nginx 不是无脑照搬的,搬一大堆注释上去是闹怎样?

南琴浪 发表于 2017-12-29 08:32:13

server
{
    listen 80;
    server_name www.baidu.com;
    index index.php index.html;
    root /www/wwwroot/www.baidu.com;
    access_logwww/wwwlogs/www.baidu.com.log;

    location /
    {
      proxy_pass http://www.baidu.com;
      proxy_set_header Host "www.baidu.com";
      proxy_set_header X-Forwarded-For $remote_addr;
    }

      include enable-php-54.conf;
   
    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/www.baidu.com.conf;
   
    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.project|LICENSE|README.md)
    {
      return 403;
    }
   
   
}

墨迹 发表于 2017-12-29 08:44:24

你先试试,有问题再说,你不试发这么一大推别人怎么看

dream7758521 发表于 2017-12-29 09:01:50

[*]      proxy_set_header Host $host; #$host改成www.baidu.com
[*]复制代码

gnocuil 发表于 2017-12-29 12:10:09


dream7758521 发表于 2017-12-29 09:01

我修改了系统的hosts把域名指向了一个ip,这个地方好像就不需要改了.

gnocuil 发表于 2017-12-29 09:01:00


墨迹 发表于 2017-12-29 08:44

你先试试,有问题再说,你不试发这么一大推别人怎么看
能正常,打开速度还挺快的,但是后端机器CPU占用了60以上,一直维持,不知道是不是html没有缓存成功。

gnocuil 发表于 2017-12-29 12:11:22


南琴浪 发表于 2017-12-29 08:32

server
{
    listen 80;
大佬 ,您这个应该是不缓存的是吧。

gnocuil 发表于 2017-12-29 08:44:00


南琴浪 发表于 2017-12-29 08:25

我真的要被这些模板气疯了。都说了 nginx 不是无脑照搬的,搬一大堆注释上去是闹怎样? ...
这些注释是宝塔自带的
页: [1]
查看完整版本: 帮忙看看这个nginx反向代理配置对不对