zoukankan      html  css  js  c++  java
  • nginx反代及后端web配置

    一、反代配置,proxy_pass指向的upstream需要在反代的nginx.conf中配置

    server {
    access_log /home/nginx/front_access.log;
    error_log /home/nginx/front-errors.log;
    ssl on;
    ssl_certificate system/project/ssl/certificate.crt;
    ssl_certificate_key system/project/ssl/private.key;
    listen 443;
    server_name ABC.com www.ABC.com;
    location ~ .*.(gif|jpg|png|htm|html|flv|ico|swf)(.*) {
    proxy_pass https://baiduhttps;

    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_cache cache_one;
    proxy_cache_valid 200 302 1h;
    proxy_cache_valid 301 1d;
    proxy_cache_valid any 1m;
    expires 30d;
    }

    location / {
    proxy_next_upstream off;
    proxy_connect_timeout 50s;
    proxy_send_timeout 50s;
    proxy_read_timeout 50s;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass https://baiduhttps;
    }
    }

    server {
    access_log /home/nginx/front_access.log;
    error_log /home/nginx/nuoya-errors99.log;

    listen 443;
    ssl on;
    ssl_certificate system/project/ssl/certificate.crt;
    ssl_certificate_key system/project/ssl/private.key;

    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/system/project/ssl/dhparam.pem;
    add_header Strict-Transport-Security "max-age=80720000; preload";

    server_name wap.ABC.com;
    location ~ .*.(gif|jpg|png|htm|html|flv|ico|swf)(.*) {
    proxy_pass https://baiduwaps;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_cache cache_one;
    proxy_cache_valid 200 302 1h;
    proxy_cache_valid 301 1d;
    proxy_cache_valid any 1m;
    expires 30d;
    }
    location / {
    proxy_next_upstream off;
    proxy_connect_timeout 50s;
    proxy_send_timeout 50s;
    proxy_read_timeout 50s;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass https://baiduwaps;
    }
    }

    二、后端web配置

    server {
    root /var/www/project/;
    index index.php;
    listen 443;
    ssl on;
    ssl_certificate vhost/ssl/certificate.crt;
    ssl_certificate_key vhost/ssl/private.key;
    access_log /home/wwwlogs/front_access.log main;
    server_name ABC.com www.ABC.com;
    set $flag 0;
    if ($request_uri ~ ".php" ){
    set $flag "${flag}1";
    }
    if ($request_uri !~ "index.php" ){
    set $flag "${flag}2";
    }
    if ($flag = "012") {
    rewrite ^(.*) http://$host/index.php/ permanent;
    }

    location / {
    try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;


    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }

    if (!-f $request_filename)
    {
    rewrite ^(.+)$ /index.php?_url=$1 last;
    }
    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?_url=$1 last;
    break;
    }

    location ~ .php$ {
    include enable-php.conf;
    }

    }

    server {
    root /var/www/wap/;
    index index.php index.html index.htm;
    listen 443;
    ssl on;
    ssl_certificate vhost/ssl/certificate.crt;
    ssl_certificate_key vhost/ssl/private.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /usr/local/nginx/conf/vhost/ssl/dhparam.pem;
    add_header Strict-Transport-Security "max-age=80720000; preload";
    server_name wap.ABC.com;

    access_log /home/wwwlogs/front_access.log main;
    set $flag 0;
    if ($request_uri ~ ".php" ){
    set $flag "${flag}1";
    }
    if ($request_uri !~ "index.php" ){
    set $flag "${flag}2";
    }
    if ($flag = "012") {
    rewrite ^(.*) http://$host/index.php/ permanent;
    }

    location / {
    try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }

    if (!-f $request_filename)
    {
    rewrite ^(.+)$ /index.php?_url=$1 last;
    }
    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?_url=$1 last;
    break;
    }
    location ~ .php$ {
    fastcgi_pass unix:/dev/shm/php-fpm.sock;
    include enable-php.conf;
    }

    }

  • 相关阅读:
    Account Inquiry (总账与子账的关联 Cost Management Receiving)
    灵活的数据管理和展示javascript类库 Recline.js
    分享23款使用纯CSS3生成的知名logo设计
    支持响应式布局的超棒颜色选择器 colorjoe
    兄弟割席:HTML5标准制定组织分裂
    30个绝对让你惊叹的幽默创意广告设计
    免费图标素材:47套最新的超棒免费图标集
    使用java的html解析器jsoup和jQuery实现一个自动重复抓取任意网站页面指定元素的web应用
    免费素材下载:一套漂亮的卡通UI界面
    分享10个超赞的画布Canvas,SVG和CSS3相关的jQuery插件
  • 原文地址:https://www.cnblogs.com/leon2659/p/10185568.html
Copyright © 2011-2022 走看看