国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

nginx ssl證書配置

這篇具有很好參考價值的文章主要介紹了nginx ssl證書配置。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。


前言

linux服務(wù)器nginx配置ssl證書。


一、ssl證書

需要申請域名,然后域名解析到你的外網(wǎng)服務(wù)器ip,然后申請ssl證書,然后下載下來,一般ssl證書可以通過 tomcat nginx等配置;

二、nginx配置ssl證書

  1. 更新yum
yum update yum
  1. gcc安裝
yum -y install gcc gcc-c++ autoconf automake make
  1. 其他安裝
yum -y install zlib zlib-devel pcre-devel openssl openssl-devel
  1. 找個位置下載nginx 例如: /usr/local/src
wget https://nginx.org/download/nginx-1.24.0.tar.gz
  1. 當(dāng)前位置解壓
tar -zxvf nginx-1.24.0.tar.gz
  1. 創(chuàng)建用戶組 用戶
groupadd nginx
useradd nginx -g nginx -s /sbin/nologin -M
  1. 進(jìn)入解壓后的目錄 編譯nginx并加入ssl 安裝
# 配置ssl
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --user=nginx --group=nginx
# 安裝編譯
make &&make install
  1. 修改nginx文件夾歸屬
chown -R nginx:nginx /usr/local/nginx
  1. 可在安裝路徑中 /usr/local/nginx/sbin 啟動nginx
#啟動
./nginx
#重啟
./nginx -s reload
#關(guān)閉
./nginx -s stop
#驗證配置nginx.conf正確
./nginx -t
  1. 訪問地址 ip 是否能看到nginx默認(rèn)頁面.ok后,停止nginx
  2. 下載證書 改名字,上傳到nginx的安裝目錄的conf的cert文件下 默認(rèn)安裝位置為: /usr/local/nginx/conf/cert
server.crt
server.key
  1. 修改nginx.conf 所在位置為 /usr/local/nginx/conf
    ● 代理vue前端頁面
    ● 代理后端接口為/api/ 去掉此前綴 轉(zhuǎn)發(fā)到服務(wù)器的9000端口
#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;

        location / {
            # 前端地址在 /usr/local/nginx/html/dist
            root   html/dist/;
            index  index.html index.htm;
            # 刷新404
            try_files $uri $uri/ /index.html;
        }

      # 代理服務(wù)端接口
	    location /api/ {
	           default_type  application/json;
	           proxy_pass http://ip:9000;
	           rewrite /api/(.*) /$1 break;
	           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_pass_request_headers on;
	           proxy_next_upstream error timeout;
	     }
        #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;
        }
    }
}
  1. 配置證書的完整 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  localhost;

        location / {
            root   html/dist/;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }

         # 代理服務(wù)端接口
	    location /dev-api/ {
	           default_type  application/json;
	           proxy_pass http://ip:9000;
	           rewrite /dev-api/(.*) /$1 break;
	           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_pass_request_headers on;
	           proxy_next_upstream error timeout;
	     }
	      # 代理圖片服務(wù)接口
	     location /image/ {
	           default_type  application/json;
	           rewrite /image/(.*) /$1 break;
	           proxy_pass https://test-lsdj.obs.cn-north-4.myhuaweicloud.com/;
	           proxy_pass_request_headers on;
	           proxy_next_upstream error timeout;
	      }

        #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 ssl 配置
    #
    server {
        listen       443 ssl;
        # 自己申請的域名
        server_name  www.baidu.com;
		
        ssl_certificate      cert/server.crt;
        ssl_certificate_key  cert/server.key;


        # 一下配置同之前的配置即可
        location / {
            root   html/dist/;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }
         # 代理服務(wù)端接口
	    location /api/ {
	           default_type  application/json;
	           proxy_pass http://ip:9000;
	           rewrite /api/(.*) /$1 break;
	           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_pass_request_headers on;
	           proxy_next_upstream error timeout;
	     }

}

13 . 可在安裝路徑中 /usr/local/nginx/sbin 啟動,驗證是否正確

./nginx

也就是相當(dāng)于,沒有ssl的時候, 配置好代理后可以用驗證完畢;
當(dāng)配置ssl的時候,之前的配置就用不到了,因為ssl是443端口,所以需要全部重新配置;并配置ssl開啟 以及證書相關(guān);

總結(jié)

至此 已經(jīng)可以成功通過域名訪問到服務(wù)器的頁面了~~文章來源地址http://www.zghlxwxcb.cn/news/detail-847057.html

到了這里,關(guān)于nginx ssl證書配置的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Nginx -- -- 配置SSL證書

    Nginx -- -- 配置SSL證書

    目錄 一,阿里云申請免費SSL證書 一,打開阿里云SSL證書頁面,點擊“選購SSL證書” 2,登錄到阿里云SSL證書管理控制臺 3,、選擇“SSL證書”–“免費證書”–“證書申請” 4,、填寫證書申請表單 ?二,nginx添加ssl證書 1,關(guān)閉防火墻核心防護(hù) ?2,創(chuàng)建一個存放證書的文件放到

    2024年02月21日
    瀏覽(16)
  • nginx 配置ssl證書方法

    到域名商哪里,申請免費ssl證書,選擇nginx版本的sll證書下載到本地,在服務(wù)器中進(jìn)入我們的nginx目錄,新建一個ssl文件夾,把下載好的ssl證書解壓放到里面。 到nginx目錄下打開nginx.conf,修改下方,代碼到文本中保存即可。 保存后重啟nginx: nginx -s reload 在 http 塊中,定義了兩

    2024年02月06日
    瀏覽(22)
  • Nginx 的SSL證書配置

    Nginx 的SSL證書配置

    目錄 1.申請域名,證書下載 2.準(zhǔn)備站點源代碼 3.修改nginx 對應(yīng)網(wǎng)站的配置文件 4.修改 host 文件 http協(xié)議訪問的網(wǎng)站默認(rèn)會顯示不安全,因為數(shù)據(jù)默認(rèn)是明文傳輸?shù)?https是http+ssl,ssl是加密協(xié)議,通過證書來進(jìn)行加密的,安裝了證書的網(wǎng)站才會用https協(xié)議來交 互,才不會提示不安

    2024年02月02日
    瀏覽(23)
  • openssl生成證書和nginx配置ssl證書

    openssl生成證書和nginx配置ssl證書

    一般情況下,使用ssl證書需要三個操作步驟:1.生成密鑰對;2.生成證書請求文件;3.生成證書文件。從單純的開發(fā)者角度來說,可以使用開源的openssl生成密鑰和證書,且通過openssl的req命令,可以一個命令完成上述3個操作。 req命令主要的功能:生成證書請求文件、驗證證書請

    2024年02月07日
    瀏覽(27)
  • http的ssl證書保姆級配置安裝-多域名 免費ssl證書 解析 nginx配置

    摘要:多個域名(mysite.com,*.mysite.com),免費證書,添加解析記錄,申請證書的shell腳本,nginx配置 登錄免費證書網(wǎng)站:https://freessl.cn/ 輸入:mysite.com,*.mysite.com 選擇亞洲誠信trustasia 點擊“創(chuàng)建免費的ssl證書” ACME域名配置 域名:確認(rèn)剛才輸入的mysite.com,*.mysite.com無誤,點擊下

    2024年02月09日
    瀏覽(376)
  • 配置https---Nginx認(rèn)證ssl證書

    配置https---Nginx認(rèn)證ssl證書

    nginx作為前端的負(fù)載均衡服務(wù)器已經(jīng)很熟悉了,項目需要使用https安全的時候就需要認(rèn)證證書了 dockerweb管理工具 Portainer 如果對docker不那么熟悉可以使用docker 第三方管理端 然后訪問本地9000端口,登錄后可以管理容器鏡像 有了該工具可以直接進(jìn)入容器查看日志等操作 nginx環(huán)境安裝

    2024年01月19日
    瀏覽(25)
  • Ubuntu安裝nginx到配置ssl證書

    1、命令安裝nginx 配置文件默認(rèn)在 /etc/nginx文件夾下面,可以編輯nginx.conf 或者 sites-enabled文件夾下面的默認(rèn)配置文件 default 2、常用命令 查看版本號 nginx -v 關(guān)閉 nginx -s stop 啟動? nginx 重新加載? nginx -s reload 檢查配置文件是否有問題? nginx -t 以特定的配置文件啟動? nginx -c? 文件

    2023年04月22日
    瀏覽(53)
  • nginx配置ssl證書使用https訪問

    nginx配置ssl證書使用https訪問

    一:申請證書,我使用的是阿里云免費證書 二:下載證書,解壓到服務(wù)器上 兩個文件:www.xx.com.pem和www.xx.com.key 三:打開配置文件/usr/local/nginx/conf/nginx.conf 放開端口443,替換ssl_certificate和ssl_certificate_key為自己證書路徑 ? ?server { ? ? ? ? listen ? ? ? 443 ssl; ? ? ? ? server_na

    2024年01月20日
    瀏覽(33)
  • docker安裝nginx并配置ssl證書

    docker安裝nginx并配置ssl證書

    騰訊云申請 阿里云申請 還有一步DNS驗證,因為我這邊已經(jīng)申請了證書,不好演示了。也挺簡單的,按照教程來就行了,在域名解析里面加一條DNS解析記錄,然后點擊驗證,通過了,就申請成功了,然后下載nginx版本的證書壓縮包,解壓上傳到服務(wù)器就可以了 *稍微需要注意下

    2024年02月05日
    瀏覽(37)
  • Nginx中的SSL加密配置與證書生成

    Nginx中的SSL加密配置與證書生成

    目錄 整體的操作流程 二、然后配置網(wǎng)絡(luò)yum源 并mv CentOS-* backup挪動到上層目錄中 ?三、在家目錄下解壓 文件,并查看 ?四、添加兩種編譯模塊./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module 五、 顯示少什么就 yum install (缺少的依賴的名稱)-devel 下圖為

    2024年02月05日
    瀏覽(16)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包