设为首页收藏本站

ZMX - IT技术交流论坛 - 无限Perfect,追求梦想 - itzmx.com

 找回密码
 注册论坛

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

用百度帐号登录

只需两步,快速登录

搜索
查看: 2295|回复: 0

nginx简易反向代理配置文件并且启用https 虚拟主机开启ssl h2反代功能

[复制链接]
 成长值: 87

签到天数: 4523 天

[LV.Master]伴坛终老

发表于 2018/4/13 03:53 | 显示全部楼层 |阅读模式 |Google Chrome 65.0.3325.181|Windows 10
天涯海角搜一下: 百度 谷歌 360 搜狗 有道 雅虎 必应 即刻
反代配置,目标回源IP:45.76.141.239
反代域名:www.itzmx.com

自己参考改,也是自己以前用过的,当初的配置文件来自互联网检索
现在几乎全套kangle,完全抛弃nginx,nginx吞吐并发性能不行。。

主机配置文件,如果不了解不要轻易修改
  1. user  www www;
  2. worker_processes auto;
  3. error_log  /home/log/nginx_error.log  crit;
  4. pid        /home/log/nginx.pid;
  5. worker_rlimit_nofile 51200;

  6. events
  7.     {
  8.         use epoll;
  9.         worker_connections 51200;
  10.         multi_accept on;
  11.     }

  12. http
  13.     {
  14.         include       mime.types;
  15.                 #include luawaf.conf;

  16.                 include proxy.conf;

  17.         default_type  application/octet-stream;

  18.         server_names_hash_bucket_size 512;
  19.         client_header_buffer_size 32k;
  20.         large_client_header_buffers 4 32k;
  21.         client_max_body_size 50m;

  22.         sendfile   on;
  23.         tcp_nopush on;

  24.         keepalive_timeout 60;

  25.         tcp_nodelay on;

  26.         fastcgi_connect_timeout 300;
  27.         fastcgi_send_timeout 300;
  28.         fastcgi_read_timeout 300;
  29.         fastcgi_buffer_size 64k;
  30.         fastcgi_buffers 4 64k;
  31.         fastcgi_busy_buffers_size 128k;
  32.         fastcgi_temp_file_write_size 256k;
  33.                 fastcgi_intercept_errors on;

  34.         gzip on;
  35.         gzip_min_length  1k;
  36.         gzip_buffers     4 16k;
  37.         gzip_http_version 1.1;
  38.         gzip_comp_level 2;
  39.         gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
  40.         gzip_vary on;
  41.         gzip_proxied   expired no-cache no-store private auth;
  42.         gzip_disable   "MSIE [1-6]\.";

  43.         limit_conn_zone $binary_remote_addr zone=perip:10m;
  44.                 limit_conn_zone $server_name zone=perserver:10m;

  45.         server_tokens off;
  46.         access_log off;

  47. server
  48.     {
  49.         listen 80;
  50.         server_name nginx.org;
  51.         index index.html index.htm index.php;
  52.         root  /home/wwwroot/nginx.org;

  53.         #error_page   404   /404.html;
  54.         include enable-php.conf;

  55.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  56.         {
  57.             expires      30d;
  58.         }

  59.         location ~ .*\.(js|css)?$
  60.         {
  61.             expires      12h;
  62.         }

  63.         location ~ /\.
  64.         {
  65.             deny all;
  66.         }

  67.         access_log  /home/log/access.log;
  68.     }
  69. include /home/nginx/*.conf;
  70. }
复制代码


虚拟主机配置文件
  1. server
  2. {
  3.     listen 80;
  4.         listen 443 ssl http2;
  5.     server_name www.itzmx.com;
  6.     index index.php index.html index.htm default.php default.htm default.html;
  7.     root /home/wwwroot/www.itzmx.com;
  8.    
  9.     #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
  10.     #error_page 404/404.html;
  11.     ssl_certificate    /home/crt/www.itzmx.com.crt;
  12.     ssl_certificate_key    /home/crt/www.itzmx.com.key;
  13.     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  14.     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  15.     ssl_prefer_server_ciphers on;
  16.     ssl_session_cache shared:SSL:10m;
  17.     ssl_session_timeout 10m;
  18.     error_page 497  https://$host$request_uri;

  19.     #SSL-END
  20.    
  21.     #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
  22.     error_page 404 /404.html;
  23.     error_page 502 /502.html;
  24.     #ERROR-PAGE-END
  25.    
  26.     #PHP-INFO-START  PHP引用配置,可以注释或修改

  27.         #PROXY-START
  28.     location ~ /purge(/.*) {
  29.         proxy_cache_purge cache_one $host$request_uri$is_args$args;
  30.         #access_log  /home/log/www.itzmx.com_purge_cache.log;
  31.     }
  32.     location /
  33.     {
  34.         proxy_pass http://45.76.141.239;
  35.         proxy_set_header Host $host;
  36.         proxy_set_header X-Real-IP $remote_addr;
  37.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  38.         proxy_set_header REMOTE-HOST $remote_addr;
  39.         
  40.         #缓存相关配置
  41.         proxy_cache cache_one;
  42.         proxy_cache_key $host$request_uri$is_args$args;
  43.         proxy_cache_valid 200 304 301 302 1h;
  44.         
  45.         #持久化连接相关配置
  46.         #proxy_connect_timeout 30s;
  47.         #proxy_read_timeout 86400s;
  48.         #proxy_send_timeout 30s;
  49.         #proxy_http_version 1.1;
  50.         #proxy_set_header Upgrade $http_upgrade;
  51.         #proxy_set_header Connection "upgrade";
  52.         
  53.         add_header X-Cache $upstream_cache_status;
  54.         
  55.         expires 12h;
  56.     }
  57.    
  58.     location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$
  59.     {
  60.         proxy_set_header Host $host;
  61.         proxy_set_header X-Real-IP $remote_addr;
  62.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  63.         proxy_set_header REMOTE-HOST $remote_addr;
  64.         proxy_pass http://45.76.141.239;
  65.         
  66.     }
  67.     #PROXY-END

  68.         include enable-php-54.conf;
  69.     #PHP-INFO-END
  70.    
  71.     #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
  72.     include /home/htaccess/www.itzmx.com.conf;
  73.     #REWRITE-END
  74.    
  75.     #禁止访问的文件或目录
  76.     location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
  77.     {
  78.         return 404;
  79.     }
  80.    
  81.     access_log  /home/log/www.itzmx.com.log;
  82.     error_log  /home/log/www.itzmx.com.error.log;
  83. }
复制代码


欢迎光临IT技术交流论坛:http://bbs.itzmx.com/
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册论坛 新浪微博账号登陆用百度帐号登录

本版积分规则

手机版|Archiver|Mail me|网站地图|IT技术交流论坛 ( 闽ICP备13013206号-7 )

GMT+8, 2024/5/23 15:31 , Processed in 0.118529 second(s), 20 queries , MemCache On.

Powered by itzmx! X3.4

© 2011- sakura

快速回复 返回顶部 返回列表