.前端nginx主配置文件

# cat nginx.conf
worker_processes ; #pid logs/nginx.pid;
pid /data/www/logs/nginx.pid; worker_rlimit_nofile ; events {
use epoll;
worker_connections ;
accept_mutex off;
} http {
include mime.types;
default_type application/octet-stream;
#set_real_ip_from 0.0.0.0/;
#real_ip_header X-Forwarded-For; #proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $http_x_forwarded_for;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_headers_hash_max_size ;
proxy_headers_hash_bucket_size ; ssl_session_cache shared:SSL:200m;
ssl_session_timeout 15m; lua_package_path "/usr/local/nginx/conf/ngx_lua_waf/?.lua";
lua_shared_dict limit 10m;
init_by_lua_file /usr/local/nginx/conf/ngx_lua_waf/init.lua;
access_by_lua_file /usr/local/nginx/conf/ngx_lua_waf/waf.lua; log_format main '$remote_addr - - [$time_local] - - "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_cookie" "$request_body" "$http_user_agent" $request_time ';
log_format error '$remote_addr - - [$time_local] - - "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_time '; sendfile on;
tcp_nodelay on; keepalive_timeout ;
#----for upload file
client_max_body_size 8M;
client_body_buffer_size 2M;
#--- for resolve error
client_header_buffer_size 64k;
large_client_header_buffers 64k;
proxy_connect_timeout 90s;
proxy_read_timeout 90s;
proxy_send_timeout 90s;
proxy_buffer_size 16k;
proxy_buffers 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_ignore_client_abort on;
proxy_intercept_errors on;
gzip on;
gzip_vary off;
gzip_min_length 1k;
gzip_buffers 16k;
gzip_http_version 1.0;
gzip_comp_level ;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/css text/javascript application/javascript application/x-javascript text/xml application/xml application/wasm; ssi on;
ssi_silent_errors on;
#ssi_types text/shtml;
expires 60d;
server_names_hash_bucket_size ;
#if_modified_since before;
#limit_req_zone $binary_remote_addr zone=all_zone:10m rate=3r/s;
#limit_req zone=all_zone burst= nodelay; # apache和php部分
upstream php_pool{
ip_hash;
server 192.168.254.122: max_fails= fail_timeout=30s weight=;
server 192.168.254.123: max_fails= fail_timeout=30s weight=; check interval= rise= fall= timeout= type=tcp port=;
check_keepalive_requests ;
# check_http_send "HEAD / HTTP/1.1\r\nConnection: keep-alive\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
} # nginx和fastcgi部分
upstream www_servers{
ip_hash;
server 192.168.254.1: max_fails= fail_timeout=30s weight=;
server 192.168.254.2: max_fails= fail_timeout=30s weight=; check interval= rise= fall= timeout= type=tcp port=;
check_keepalive_requests ;
# check_http_send "HEAD / HTTP/1.1\r\nConnection: keep-alive\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
} include vhost.d/*.conf;
server {
listen 80 default_server;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root /data/www/html;
index index.html index.htm;
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} location /status {
stub_status on;
access_log off;
} }
} nginx前端的虚拟主机配置 [root@web01:/usr/local/nginx/conf/vhost.d]# more drfone.chinasoft.com.conf
server {
listen 80;
server_name drfone.chinasoft.com ori-drfone.chinasoft.com www.drfone.chinasoft.com;
access_log /data/www/logs/nginx_log/access/drfone.chinasoft.com_access.log main ;
error_log /data/www/logs/nginx_log/error/drfone.chinasoft.com_error.log ;
root /data/www/vhosts/drfone.chinasoft.com/httpdocs ;
index index.html index.shtml index.php ;
include rewrite.d/drfone.chinasoft.com.conf ;
error_page 404 403 /404.html; rewrite ^/(.*)$ https://drfone.chinasoft.com/$1 permanent; #跳转到Https location ~ \.php$ {
proxy_pass http://php_pool;
include proxy_params;
expires -1;
} location / {
include proxy_params;
if (!-d $request_filename){
set $flag 1$flag;
}
if (!-f $request_filename){
set $flag 2$flag;
}
if ($flag = "21"){
proxy_pass http://php_pool;
expires -1;
} } } server {
listen 443;
ssl on; ssl_certificate cert2016/chinasoft_com.crt;
ssl_certificate_key cert2016/chinasoft_com.key;
ssl_dhparam cert2016/dh_2048.pem; ssl_session_timeout 15m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AE
S256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!AES128-GCM-SHA256:!AES256-GCM-SHA384:!AES128-SHA256:!AES256-SHA256:!AES128-SHA:!AES256-SHA:AES:!CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:EDH-RSA-DES-CBC3
-SHA:!KRB5-DES-CBC3-SHA"; ssl_prefer_server_ciphers on; #ssl_stapling on;
#ssl_stapling_verify on; server_name drfone.chinasoft.com ori-drfone.chinasoft.com;
access_log /data/www/logs/nginx_log/access/drfone.chinasoft.com_access.log main ;
error_log /data/www/logs/nginx_log/error/drfone.chinasoft.com_error.log ; root /data/www/vhosts/drfone.chinasoft.com/httpdocs ;
index index.html index.shtml index.php ;
include rewrite.d/drfone.chinasoft.com.conf ;
error_page 404 403 /404.html; if ($http_user_agent ~ Ezooms) {
return 403;
} location ^~ /servers/ {
include proxy_params;
proxy_http_version 1.1;
proxy_pass http://www_servers;
expires -1;
} location ~ \.php$ {
proxy_pass http://php_pool;
expires -1;
include proxy_params;
} } 2.当后端是apache+php时的apache配置部分 [root@web01:/usr/local/nginx/conf/vhost.d]# more /usr/local/httpd-2.2.26/conf/vhost.d/drfone.chinasoft.com.conf
<VirtualHost *:8080>
ServerName drfone.chinasoft.com
    # apache配置别名,相当于多个域名都可以访问进来
  ServerAlias drfone.chinaosft.com
     ServerAlias drfone.chinaosft-mac.com UseCanonicalName Off
ServerAdmin "admin@chinasoft.com"
DocumentRoot /data/www/vhosts/drfone.chinasoft.com/httpdocs
DirectoryIndex index.html index.shtml index.php
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /data/www/logs/apache_log/access/drfone.chinasoft.com_access.log.%Y-%m-%d 86400" combined
ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /data/www/logs/apache_log/error/drfone.chinasoft.com_error.log.%Y-%m-%d 86400"
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
<Directory /data/www/vhosts/drfone.chinasoft.com/httpdocs/>
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir ".:/data/www/vhosts/drfone.chinasoft.com:/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir ".:/data/www/vhosts/drfone.chinasoft.com:/tmp"
</IfModule>
Options -ExecCGI FollowSymLinks +Includes
AllowOverride All
</Directory> Alias /servers "/data/www/vhosts/www_servers"
<Directory "/data/www/vhosts/www_servers/">
Options -ExecCGI FollowSymLinks +Includes
AllowOverride All
</Directory> ErrorDocument 404 /404.html </VirtualHost> 3.当后端为nginx+php+fastcgi时
[root@ws_cbs_frontend_web01:/usr/local/nginx/conf/vhost.d]# more ../other_domain.d/drfone.chinasoft.com.conf
server {
listen 80;
server_name drfone.chinasoft.com ori-drfone.chinasoft.com;
access_log /data/www/logs/nginx_log/access/drfone.chinasoft.com_access.log main ;
error_log /data/www/logs/nginx_log/error/drfone.chinasoft.com_error.log ;
root /data/www/vhosts/www_servers ;
index index.html index.shtml index.php ;
include rewrite.d/drfone.chinasoft.com.conf ;
error_page 404 403 /404.html;
set_real_ip_from 192.168.0.0/16;
set_real_ip_from 10.10.18.0/24;
#set_real_ip_from 0.0.0.0/0;
real_ip_header X-Real-IP;
location / {
try_files $uri $uri/ /index.php?$query_string;
} location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }
server {
listen 443;
server_name drfone.chinasoft.com ori-drfone.chinasoft.com;
access_log /data/www/logs/nginx_log/access/drfone.chinasoft.com_access.log main ;
error_log /data/www/logs/nginx_log/error/drfone.chinasoft.com_error.log ;
root /data/www/vhosts/www_servers ;
index index.html index.shtml index.php ;
include rewrite.d/drfone.chinasoft.com.conf ;
error_page 404 403 /404.html;
ssl on; ssl_certificate cert2016/chinasoft_com.crt;
ssl_certificate_key cert2016/chinasoft_com.key;
ssl_dhparam cert2016/dh_2048.pem; ssl_session_timeout 15m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AE
S256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!AES128-GCM-SHA256:!AES256-GCM-SHA384:!AES128-SHA256:!AES256-SHA256:!AES128-SHA:!AES256-SHA:AES:!CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:EDH-RSA-DES-CBC3
-SHA:!KRB5-DES-CBC3-SHA"; set_real_ip_from 192.168.0.0/16;
set_real_ip_from 10.10.18.0/24;
#set_real_ip_from 0.0.0.0/0;
real_ip_header X-Real-IP;
location / {
try_files $uri $uri/ /index.php?$query_string;
} location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }

apache启用ssi功能

# more .htaccess
RewriteOptions inherit

RewriteEngine on

<IfModule include_module>
   Options +IncludesNoExec
</IfModule>

AddType text/html .shtml  .html  .htm
AddOutputFilter INCLUDES .shtml  .html  .htm

nginx反向代理结合apache和php的配置示例的更多相关文章

  1. nginx 反向代理 与 Apache backend的配置联合配置

    nginx 反向代理 与 Apache backend的配置联合配置: 说明: nginx 将http映射到Apache上的特定子目录. 配置方法步骤: 1.  设置域名, 子域名映射到指定服务器ip ...

  2. nginx反向代理和负载均衡的基本配置

    一.反向代理的基本配置 在原本默认的nginx上修改server配置 server { listen 2222;#监听请求端口 server_name 192.168.100.3;#监听请求地址,ng ...

  3. linux系统下使用nginx反向代理asp.net core,并配置免费的https证书

    反向代理是为动态 Web 应用提供服务的常见设置. 反向代理终止 HTTP 请求,并将其转发到 ASP.NET Core 应用. 1.在asp.net core项目中的Startup的Configur ...

  4. nginx反向代理转发apache配置 之 cookie去哪儿了?

    在公司接手了个微信项目,由于微信环境下访问网站需要使用对外开放的域名,所以有相关问题,都是直接运维同事帮忙处理. 原理是这样: 方案一: 1. 将域名解析指向测试服务器的地址: 2. 开放相关端口访问 ...

  5. Nginx反向代理+负载均衡简单实现(http方式)

    1)nginx的反向代理:proxy_pass2)nginx的负载均衡:upstream 下面是nginx的反向代理和负载均衡的实例: 负载机:A机器:103.110.186.8/192.168.1. ...

  6. Nginx反向代理的简单实现

    1)nginx的反向代理:proxy_pass2)nginx的负载均衡:upstream 下面是nginx的反向代理和负载均衡的实例: 负载机:A机器:103.110.186.8/192.168.1. ...

  7. 【nginx网站性能优化篇(2)】反向代理实现Apache与Nginx的动静分离(LNMPA)

    为什么要使用反向代理 具体请参考这篇博文:[Linux常识篇(1)]所谓的正向代理与反向代理 在虚拟机上配置反向代理的步骤 首先假设你已经假设好了LNMP架构了,这时我们还要安装Apache和php, ...

  8. nginx 反向代理 apache 服务

    反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时 ...

  9. 15 nginx反向代理实现nginx+apache动静分离

    一:nginx反向代理实现nginx+apache动静分离-------------概念--------------------------- nginx反向代理服务器+负载均衡 用nginx做反向代 ...

随机推荐

  1. Vue+Django项目部署

    本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改luffy/settings/prop.py中以下几项 (1) allow_hosts ALLOWED_HOST ...

  2. Codeforces F. Vus the Cossack and Numbers(贪心)

    题目描述: D. Vus the Cossack and Numbers Vus the Cossack has nn real numbers aiai. It is known that the ...

  3. Kotlin中Range与异常体系剖析

    好用的集合扩展方法: 下面来看一下对于集合中好用的一些扩展方法,直接上代码: 如果我们想取出集合中的第一个值和最后一个值,用Java方式是get(0)和get(size-1),但是在Kotlin中提供 ...

  4. Uva1349Optimal Bus Route Design(二分图最佳完美匹配)(最小值)

    题意: 给定n个点的有向图问,问能不能找到若干个环,让所有点都在环中,且让权值最小,KM算法求最佳完美匹配,只不过是最小值,所以把边权变成负值,输出时将ans取负即可 这道题是在VJ上交的 #incl ...

  5. keras神经网络开发知识笔记

    mnist数据集获取60000个训练样本和10000个测试样本,样本为0-9十个数字,用全连接神经网络进行训练,并测试结果. 例程采用60000个数据样本进行训练,对于一般的电脑来说,这样训练会比较费 ...

  6. jq function return value

    所有 JS  函数 都会返回值 假如 没有 return  则返回 undefined

  7. invoke和begininvoke 区别

    一直对invoke和begininvoke的使用和概念比较混乱,这两天看了些资料,对这两个的用法和原理有了些新的认识和理解. 首先说下,invoke和begininvoke的使用有两种情况: 1. c ...

  8. 极限挑战----3小时完成OA系统(失败)

    今天老师要求三小时把OA系统做出了,之前一点也没接触过,对其不了解,而且这几天一直把时间放在六级了,对Web重视有点少. 最终我只做了登录和校验,可以显示富文本框,但不能提交数据库. 总之还有还多没有 ...

  9. 003-转载-keil-STM32硬件错误HardFault_Handler的处理方法

    (一)参考文献:https://blog.csdn.net/electrocrazy/article/details/78173558 在用Keil对STM32的程序进行仿真时程序有时会跑飞,停止仿真 ...

  10. dinoql 使用nodejs 运行的几个问题

    dinoql 是一个很不错的javascript objects 查询处理方案,基于graphql,当前版本有点问题 node 环境运行 ReferenceError: window is not d ...