1、阿里云域名申請
買到域名之后,要對域名進(jìn)行實名認(rèn)證(上傳身份證并拍照)(阿里云審核一天)
2、域名工信部備案
1、阿里云域名備案,這個也要實名認(rèn)證,其中阿里云員工審核并打電話(半天左右)
2、工信部短信驗證,直接把驗證碼,身份證短信驗證一下就行(短信時間一兩天左右),并提交管局審核
3、域名資料交管局審核(一個星期左右),時間久一些,具體看一看短信時間
3、申請阿里云免費ssl證書,阿里云單域名證書
2、網(wǎng)上申請證書的教程很多大同小異,但是現(xiàn)在阿里云免費證書頁面改版了,有一點點不同
3、證書申請并下載
4、配置阿里云免費證書
1、Nginx配置證書
原本的config原生頁面如下
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
可以查看Nginx部署證書的幫助文檔
2、我結(jié)合文檔總結(jié)一下
1、下載到配置好域名的證書,服務(wù)器自定義的文件夾下面
2、在需要的端口配置證書位置,和方式
3、開放443端口
下面是阿里云443配置的代碼
#以下屬性中,以ssl開頭的屬性表示與證書配置有關(guān)。
server {
listen 443 ssl;
#配置HTTPS的默認(rèn)訪問端口為443。
#如果未在此處配置HTTPS的默認(rèn)訪問端口,可能會造成Nginx無法啟動。
#如果您使用Nginx 1.15.0及以上版本,請使用listen 443 ssl代替listen 443和ssl on。
server_name yourdomain.com; #需要將yourdomain.com替換成證書綁定的域名。
root html;
index index.html index.htm;
ssl_certificate cert/cert-file-name.pem; #需要將cert-file-name.pem替換成已上傳的證書文件的名稱。
ssl_certificate_key cert/cert-file-name.key; #需要將cert-file-name.key替換成已上傳的證書密鑰文件的名稱。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的類型。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS協(xié)議的類型。
ssl_prefer_server_ciphers on;
location / {
root html; #站點目錄。
index index.html index.htm;
}
}
3、我的配置帶證書的nginx.conf如下
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name www.jianghaojie.xyz; #需要將yourdomain.com替換成證書綁定的域名。
#配置的證書
listen 443 ssl;
ssl_certificate cert/5883433_www.jianghaojie.xyz.pem; #需要將cert-file-name.pem替換成已上傳的證書文件的名稱。
ssl_certificate_key cert/5883433_www.jianghaojie.xyz.key; #需要將cert-file-name.key替換成已上傳的證書密鑰文件的名稱。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的類型。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS協(xié)議的類型。
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
在server中主要添加的東西如下,配置pom 和key的地址
listen 443 ssl;
ssl_certificate cert/5883433_www.jianghaojie.xyz.pem; #需要將cert-file-name.pem替換成已上傳的證書文件的名稱。
ssl_certificate_key cert/5883433_www.jianghaojie.xyz.key; #需要將cert-file-name.key替換成已上傳的證書密鑰文件的名稱。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的類型。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS協(xié)議的類型。
ssl_prefer_server_ciphers on;
4、重啟nginx
cd /usr/local/nginx/sbin
./nginx -s reload
5、開放443端口
阿里云上開放443端口
6、服務(wù)器上開放443端口,并重啟防火墻
# 增加443端口
firewall-cmd --zone=public --add-port=443/tcp --permanent
# 重啟防火墻
firewall-cmd --reload
重啟好了打開你的頁面,帶https的就能訪問了
nginx反向代理多個后臺端口
因為多個小程序部署,所以需要使用到多個后臺,這樣就需要nginx做反向代理,一個服務(wù)器只能安裝一個ssl證書綁定80端口,所以這里用nginx代理來解決,
上面已經(jīng)配置好了nginx及域名證書了,下面開始配置多個IP加端口
如下所示
location / {
root html;
index index.html index.htm;
}
location /xx{
proxy_pass http://你的ip:你的端口/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /yy{
proxy_pass http://IP:端口/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
這樣就可以通過不同的/xx 或者 /yy 來區(qū)別代理不同的地址了。
https代理多個vue項目
server {
listen 443 ssl;
server_name 域名; #需要將yourdomain.com替換成證書綁定的域名。
#配置的證書
ssl_certificate cert/public.pem; #需要將cert-file-name.pem替換成已上傳的證書文件的名稱。
ssl_certificate_key cert/private.key; #需要將cert-file-name.key替換成已上傳的證書密鑰文件的名稱。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的類型。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS協(xié)議的類型。
ssl_prefer_server_ciphers on;
#項目一
location / {
root /home/dbxq/dl/dist; #dist文件的位置(根據(jù)自己dist包放置的位置決定)
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
#項目二
location /ht {
alias /home/dbxq/ht/dist/;
try_files $uri $uri/ /ht/index.html;
index index.html;
}
#項目minio配置
location /fileShow/ {
proxy_pass http://172.43.130.196:9000/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#后端接口配置配置
location /prod-api/ {
proxy_pass http://172.43.130.195:7006/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}文章來源:http://www.zghlxwxcb.cn/news/detail-488224.html
2、 第一個項目直接用/ 就可以訪問,第二個因為加了/ht ,所以在vue.config.js下面的publicPath要改路徑 ,
這樣打包的dist文件夾下面的index.html可以看到如下這樣,就OK了文章來源地址http://www.zghlxwxcb.cn/news/detail-488224.html
到了這里,關(guān)于阿里云申請域名及域名配置https的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!