nginx反向 Proxyhttps網站

來源:互聯網
上載者:User

標籤:nginx反向 Proxyhttps網站

基本的代理配置就不說了 現在貼出配置並強調幾點容易出錯的問題。



user              nginx;

worker_processes  1;

error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;

events {

    worker_connections  1024;

}

http {

    include       /etc/nginx/mime.types;

    default_type  application/octet-stream;

    log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘

                      ‘$status $body_bytes_sent "$http_referer" ‘

                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;

    keepalive_timeout  65;



server {

        listen       80;

        server_name  aaa.test.com;

        rewrite ^(.*) https://$server_name$1 permanent;

    }            ##這一塊用來指定rewrite


    server {

        listen       443;

        server_name  aaa.test.com;        ##如果後端是多vhost的server此處必須用真實網域名稱。

        location / {

               proxy_pass https://172.16.160.131;     ##realserver真真實位址或網域名稱

               proxy_set_header  Host $host;

               proxy_set_header  X-Real-IP  $remote_addr;

               proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

               client_max_body_size 100m;

               client_body_buffer_size 128k;

               proxy_connect_timeout 300;

               proxy_send_timeout 300;

               proxy_read_timeout 300;

               proxy_buffer_size 4k;

               proxy_buffers 4 32k;

               proxy_busy_buffers_size 64k;

               proxy_temp_file_write_size 64k;

               add_header X-Frame-Options SAMEORIGIN;

      }


      ssl                  on;

      ssl_certificate      /etc/nginx/cert/server.crt;     ##此處是realserver的網站認證,用自簽返回的就是自簽。

      ssl_certificate_key  /etc/nginx/cert/server.key;

      ssl_session_timeout  5m;

      ssl_protocols  SSLv3 TLSv1;

      ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

      ssl_prefer_server_ciphers   on;

      error_page   500 502 503 504  /50x.html;

      location = /50x.html {

          root   html;

      }

   }





    include /etc/nginx/conf.d/*.conf;


}


nginx反向 Proxyhttps網站

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.