Nginx reverse proxy https service

Source: Internet
Author: User
Tags nginx reverse proxy

Nginx reverse proxy https service

Background:

Recently, due to work requirements, you need to create a proxy on the Web Front-end to address the inaccessible needs of some users. Previously, Web Proxy has been implemented through Nginx reverse proxy, however, I found that there are other sites with https, so I found some other materials, sorted them out, and completed the test.

-------------------------------------- Split line --------------------------------------

Deployment of Nginx + MySQL + PHP in CentOS 6.2

Build a WEB server using Nginx

Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5

Performance Tuning for Nginx in CentOS 6.3

Configure Nginx to load the ngx_pagespeed module in CentOS 6.3

Install and configure Nginx + Pcre + php-fpm in CentOS 6.4

Nginx installation and configuration instructions

Nginx log filtering using ngx_log_if does not record specific logs

-------------------------------------- Split line --------------------------------------

Method:

The deployment and configuration of the Nginx proxy web site ttxsgoto.com are mainly implemented using the following script:

#! /Bin/bash

Path_soft = $ (pwd)

 


Function base (){

Yum-y install make gcc-c ++ autoconf

}

 


Function install (){

Groupadd www

Useradd-g www

 


Wget http: // 1.1.1.1/nginx/pcre-8.36.tar.gz

Tar zxvf pcre-8.36.tar.gz

Cd pcre-8.36

./Configure

Make & make install

 


Wget http: // 1.1.1.1/nginx/nginx-1.6.2.tar.gz

Tar zxvf nginx-1.6.2.tar.gz

Cd nginx-1.6.2

./Configure -- user = www -- group = www -- prefix =/usr/local/web/nginx -- with-http_stub_status_module -- with-http_ssl_module

Make & make install

}

Function config (){

Sed-I "s #\# gzip \ on ;#\# gzip \ on; \ n include \ vhosts /*. conf; # g "/usr/local/web/nginx/conf/nginx. conf

Mkdir/usr/local/web/nginx/conf/vhosts

 


Cat <EOF>/usr/local/web/nginx/conf/vhosts/ttxsgoto.com. conf

Server

{

Listen 80;

Server_name ttxsgoto.com;

Charset GB2312;

Index index.html index.htm;

Root/date/wwwroot/ttxsgoto.com /;

Location ~ ^/NginxStatus /{

Stub_status on;

Access_log off;

}

Location /{

Proxy_redirect off;

Proxy_set_header Host \ $ host;

Proxy_set_header X-Real-IP \ $ remote_addr;

Proxy_set_header REMOTE-HOST \ $ remote_addr;

Proxy_set_header X-Forwarded-For \ $ proxy_add_x_forwarded_for;

Client_max_body_size 50 m;

Client_body_buffer_size 256 k;

Proxy_connect_timeout 30;

Proxy_send_timeout 30;

Proxy_read_timeout 60;

Proxy_buffer_size 256 k;

Proxy_buffers 4 256 k;

Proxy_busy_buffers_size 256 k;

Proxy_temp_file_write_size 256 k;

Proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;

Proxy_max_temp_file_size 128 m;

Proxy_pass http://ttxsgoto.com;

}

}

Server

{

Listen 8081;

Server_name ttxsgoto.com: 8081;

Charset GB2312;

Index index.html index.htm;

Root/date/wwwroot/ttxsgoto.com /;

Location ~ ^/NginxStatus /{

Stub_status on;

Access_log off;

}

Location /{

Proxy_redirect off;

Proxy_set_header Host \ $ host;

Proxy_set_header X-Real-IP \ $ remote_addr;

Proxy_set_header REMOTE-HOST \ $ remote_addr;

Proxy_set_header X-Forwarded-For \ $ proxy_add_x_forwarded_for;

Client_max_body_size 50 m;

Client_body_buffer_size 256 k;

Proxy_connect_timeout 30;

Proxy_send_timeout 30;

Proxy_read_timeout 60;

Proxy_buffer_size 256 k;

Proxy_buffers 4 256 k;

Proxy_busy_buffers_size 256 k;

Proxy_temp_file_write_size 256 k;

Proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;

Proxy_max_temp_file_size 128 m;

Proxy_pass http://ttxsgoto.com: 8081;

}

}

EOF

Cat <EOF>/etc/hosts

2.2.2.2 ttxsgoto.com

EOF

Ln-s/usr/local/lib/libpcre. so.1/lib64/

Ulimit-SHn 51200

}

Function start (){

/Usr/local/web/nginx/sbin/nginx

}

Function main (){

Base

Install

Config

Start

}

Main

So far, the installation and configuration of the nginx proxy web have been completed. Verification Method: Modify the hosts file: x. x ttxsgoto.com locally and access the page through browsing.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.