linux nginx 443端口訪問
阿新 • • 發佈:2018-10-30
重定向 index erro $1 term nag user ive cert 我是在阿裏雲上配置443端口 首先點擊SSL證書這裏 再選擇已簽發證書下載 就會讓你選擇下載證書的類型 我這裏是nginx 就選擇nginx版本下載 如果沒有就需要購買了
- 下載好後解壓完成是這樣的文件
-
需要把他上傳到阿裏雲的服務器上
#mkdir /usr/local/nginx/conf/cert #我這裏nginx是編譯安裝
#cd /usr/local/nginx/conf/cert
#mv ~/214xxxxxxxxxxxxx.key cert .
#mv ~/214xxxxxxxxxxxxx.pem cert .
#cat nginx.conf
user nginx;
worker_processes 4;
pid conf/nginx.pid;events { worker_connections 1024; } http { include 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 /usr/local/nginx/logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; include /usr/local/nginx/conf/conf.d/*.conf; #我這裏跳轉到了另一個文件 }
#cat conf.d/xxx.conf
server {
listen 80;
server_name xxxx.com; #域名
rewrite ^(.*)$ https://${server_name}$1 permanent; #重定向
}
server {
listen 443;
server_name xxxx.com; #域名
ssl on;
ssl_certificate cert/214xxxxxxxxxxxxx.pem; #文件位置
ssl_session_timeout 5m;
ssl_ciphers xxxxx-xxx-xxx128-xxx-xxx256:xxxxx:xxxxx:xxx:xxxx:!NULL:!aNULL:!MD5:!ADH:!RC4; # 秘鑰 我這個是從阿裏雲上獲取的
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #協議
ssl_prefer_server_ciphers on;
index index.php index.htm index.html;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;location ~ \.php$ { #我這裏還有配置php root /opt/www; #網站位置 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location / { root /opt/www; #網站位置 index index.php index.html index.htm; if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; }
}
}
linux nginx 443端口訪問