Nginx Configuration and HTTPS configuration example

Source: Internet
Author: User

One, Nginx simple configuration example
User www www;worker_processesTen; #error_log logs/Error.log, #error_log logs/error.log notice; #error_log logs/error.logInfo; #pid logs/nginx.pid; #最大文件描述符worker_rlimit_nofile51200; events {use epoll; Worker_connections51200;} HTTP {include Conf/mime.types; Default_type Application/octet-stream; Keepalive_timeout -;      Tcp_nodelay on; Upstream www.xxx.com {server192.168.1.2: the; Server192.168.1.3: the; Server192.168.1.4: the; Server192.168.1.5: the; } upstream blog.xxx.com {server192.168.1.7:8080; Server192.168.1.7:8081; Server192.168.1.7:8082; } Server {Listen the;              server_name www.xxx.com; Location/{proxy_pass http://www.zyan.cc;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_next_upstream Error timeout Invalid_header http_500 http_502 http_503 http_504 http_404; } Log_format www_xxx_com'$remote _addr-$remote _user [$time _local] $request'                                '"$status" $body _bytes_sent "$http _referer"'                                '"$http _user_agent" "$http _x_forwarded_for "'; Access_log/data1/logs/Www.log www_xxx_com; } Server {Listen the;              server_name blog.xxx.com; Location/{proxy_pass http://blog.zyan.cc;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_next_upstream Error timeout Invalid_header http_500 http_502 http_503 http_504 http_404; } Log_format blog_xxx_com'$remote _addr-$remote _user [$time _local] $request'                                '"$status" $body _bytes_sent "$http _referer"'                                '"$http _user_agent" "$http _x_forwarded_for "'; Access_log/data1/logs/Blog.log blog_xxx_com; }}
Two, HTTPS configuration example
upstream xxx_xxx_xxx {server192.168.1.7:8080; Server192.168.1.7:8081; Server192.168.1.7:8082;} server {Listen443;    server_name xxx.xxx.xxx; Access_log/home/chenwebstore1/logs/xxx.xxx.xxx/https.29289080/Access.log combined; Error_log/home/chenwebstore1/logs/xxx.xxx.xxx/https.29289080/Error.log error;    SSL on; ssl_certificate Keys/Xxx.xxx.xxx.pem; Ssl_certificate_key Keys/Xxx.xxx.xxx.key;    Ssl_session_cache shared:ssl.xxx.xxx.xxx:128k; Ssl_protocols TLSv1 TLSv1.1TLSv1.2; Location/{proxy_pass http://xxx_xxx_xxx;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_next_upstream Error timeout Invalid_header http_500 http_502 http_503 http_504 http_404; }}

Where the Ssl_certificate_key file format is:

-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----

Where the ssl_certificate file format (suffix can be cer) is:

(Certificate:)
----BEGIN CERTIFICATE-----
----END CERTIFICATE-----
(Intermediate Certificate:)
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----

The above three string values can be obtained at the time of the HTTPS certificate request.

Nginx Configuration and HTTPS configuration example

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.