無意中發現了一個巨牛的人工智能教程,忍不住分享一下給大家。教程不僅是零基礎,通俗易懂,而且非常風趣幽默,像看小說一樣!覺得太牛了,所以分享給大家。點這裏可以跳轉到教程。
一些對安全性要求比較高的站點,可能會使用 HTTPS(一種使用ssl通信標準的安全HTTP協議)。
先了解一些http相關的概念:
HTTP:是互聯網上應用最爲廣泛的一種網絡協議,是一個客戶端和服務器端請求和應答的標準(TCP),用於從WWW服務器傳輸超文本到本地瀏覽器的傳輸協議,它可以使瀏覽器更加高效,使網絡傳輸減少。
HTTPS:是以安全爲目標的HTTP通道,簡單講是HTTP的安全版,即HTTP下加入SSL層,HTTPS的安全基礎是SSL,因此加密的詳細內容就需要SSL。
使用 nginx 配置 https 需要知道以下幾點:
HTTPS 的固定端口號是 443,不同於 HTTP 的 80 端口
SSL 標準需要引入安全證書,所以在 nginx.conf 中你需要指定證書和它對應的 key
其他和 http 反向代理基本一樣,只是在 Server 部分配置有些不同。配置如下:
#運行用戶
#user somebody;
#啓動進程,通常設置成和cpu的數量相等
worker_processes 1;
#全局錯誤日誌
error_log C:/Users/wangcw/Desktop/nginx-1.13.12/logs/error.log;
error_log C:/Users/wangcw/Desktop/nginx-1.13.12/logs/notice.log notice;
error_log C:/Users/wangcw/Desktop/nginx-1.13.12/logs/info.log info;
#PID文件,記錄當前啓動的nginx的進程ID
pid C:/Users/wangcw/Desktop/nginx-1.13.12/logs/nginx.pid;
#工作模式及連接數上限
events {
worker_connections 1024; #單個後臺worker process進程的最大併發鏈接數
}
#設定http服務器,利用它的反向代理功能提供負載均衡支持
http {
#設定mime類型(郵件支持類型),類型由mime.types文件定義
include C:/Users/wangcw/Desktop/nginx-1.13.12/conf/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 C:/Users/wangcw/Desktop/nginx-1.13.12/logs/access.log main;
rewrite_log on;
#sendfile 指令指定 nginx 是否調用 sendfile 函數(zero copy 方式)來輸出文件,對於普通應用,
#必須設爲 on,如果用來進行下載等應用磁盤IO重負載應用,可設置爲 off,以平衡磁盤與網絡I/O處理速度,降低系統的uptime.
sendfile on;
#tcp_nopush on;
#連接超時時間
keepalive_timeout 120;
tcp_nodelay on;
#gzip壓縮開關
#gzip on;
#設定實際的服務器列表
upstream zp_server1{
server 127.0.0.1:8077;
}
#HTTP服務器
server {
#監聽443端口。443爲知名端口號,主要用於HTTPS協議
listen 443 ssl;
#定義使用www.xx.com訪問
server_name www.aabbccdd.com;
#ssl證書文件位置(常見證書文件格式爲:crt/pem)
ssl_certificate cert.pem;
#ssl證書key位置
ssl_certificate_key cert.key;
#ssl配置參數(選擇性配置)
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
#數字簽名,此處使用MD5
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /root;
index index.html index.htm;
}
#編碼格式
charset utf-8;
#代理配置參數
proxy_connect_timeout 180;
proxy_send_timeout 180;
proxy_read_timeout 180;
proxy_set_header Host $host;
proxy_set_header X-Forwarder-For $remote_addr;
#反向代理的路徑(和upstream綁定),location 後面設置映射的路徑
location / {
proxy_pass http://zp_server1;
}
#靜態文件,nginx自己處理
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root C:/XMCARES_X/WorkSpace/nginx/src/main/webapp/views;
#過期30天,靜態文件不怎麼更新,過期可以設大一點,如果頻繁更新,則可以設置得小一點。
expires 30d;
}
#設定查看Nginx狀態的地址
location /NginxStatus {
stub_status on;
access_log on;
auth_basic "NginxStatus";
auth_basic_user_file conf/htpasswd;
}
#禁止訪問 .htxxx 文件
location ~ //.ht {
deny all;
}
#錯誤處理頁面(可選擇性配置)
#error_page 404 /404.html;
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
}
}
然後還需要配置域名解析:
hosts文件:
127.0.0.1 www.aabbccdd.com