最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

nginx配置https+域名訪問(wèn)springboot接口怎么操作?

 更新時(shí)間:2026年07月25日 10:06:06   作者:Bug締造者  
還在為如何通過(guò)https+域名訪問(wèn)springboot接口發(fā)愁?本文手把手教你從申請(qǐng)SSL證書(shū)、上傳到服務(wù)器、配置nginx.conf到重啟nginx,一步步實(shí)現(xiàn)安全訪問(wèn),讓你的tomcat接口輕松支持https

目標(biāo)

通過(guò)nginx配置,實(shí)現(xiàn)通過(guò)https+域名訪問(wèn)springboot部署的tomcat接口

實(shí)現(xiàn)步驟

1、首先申請(qǐng)證書(shū)

下載適用于ngxin版本的證書(shū)(.PEM格式)

2、下載壓縮包

解壓后文件夾中存在以下幾個(gè)文件:

3、將解壓后的文件

上傳至服務(wù)器中 /etc/ssl/certs 目錄下

4、修改nginx.conf文件

(1)監(jiān)聽(tīng)自己要訪問(wèn)的端口(18380),并修改服務(wù)名為域名信息,每一個(gè)虛擬主機(jī)監(jiān)聽(tīng)不同的SSL端口(默認(rèn)端口為443)

server {
    listen 18380;
	listen 1443 ssl;
	server_name www.xxx.com;
	ssl on;
	ssl_certificate /etc/ssl/certs/www.xxx.com.pem;
	ssl_certificate_key /etc/ssl/certs/www.xxx.com.key;
	ssl_session_timeout 5m;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_prefer_server_ciphers on;

 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;

         #前端資源地址
        location / {
            root   /usr/share/nginx/html;
            try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
     #后端接口訪問(wèn)地址
       location /prod-api/ {
         proxy_pass http://ip:端口/;
         client_max_body_size     50m;
         proxy_redirect     off;
         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;
         proxy_max_temp_file_size 0;
         proxy_connect_timeout      90;
         proxy_send_timeout         90;
         proxy_read_timeout         90;
         proxy_buffer_size          4k;
         proxy_buffers              4 32k;
         proxy_busy_buffers_size    64k;
         proxy_temp_file_write_size 64k;
         proxy_cookie_path / /;
 
     }
#靜態(tài)資源訪問(wèn)地址
 location /prod-api/ryK1haERqT.txt {
          alias /usr/share/nginx/html/ryK1haERqT.txt;
          allow all;
          autoindex on;
        }

(2)附完整.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 18380;
	listen 1443 ssl;
	server_name www.xxx.com;
	ssl on;
	ssl_certificate /etc/ssl/certs/www.xxx.com.pem;
	ssl_certificate_key /etc/ssl/certs/www.xxx.com.key;
	ssl_session_timeout 5m;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_prefer_server_ciphers on;

 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
        
        #前端資源地址
        location / {
            root   /usr/share/nginx/html;
            try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
        #后端接口訪問(wèn)地址
       location /prod-api/ {
         proxy_pass http://ip:端口/;
         client_max_body_size     50m;
         proxy_redirect     off;
         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;
         proxy_max_temp_file_size 0;
         proxy_connect_timeout      90;
         proxy_send_timeout         90;
         proxy_read_timeout         90;
         proxy_buffer_size          4k;
         proxy_buffers              4 32k;
         proxy_busy_buffers_size    64k;
         proxy_temp_file_write_size 64k;
         proxy_cookie_path / /;
 
     }
     

     location /prod-api/ryK1haERqT.txt {
          alias /usr/share/nginx/html/ryK1haERqT.txt;
          allow all;
          autoindex on;
        }
        #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;
    #    }
    #}
 
}

5、然后重啟nginx即可

(進(jìn)入 /usr/local/nginx/sbin,運(yùn)行./nginx 或./nginx -s reload進(jìn)行重啟)

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 基于Nginx實(shí)現(xiàn)一個(gè)灰度上線系統(tǒng)的示例代碼

    基于Nginx實(shí)現(xiàn)一個(gè)灰度上線系統(tǒng)的示例代碼

    本文主要介紹了基于Nginx實(shí)現(xiàn)一個(gè)灰度上線系統(tǒng)的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • Nginx的使用經(jīng)驗(yàn)小結(jié)

    Nginx的使用經(jīng)驗(yàn)小結(jié)

    相信很多人都聽(tīng)過(guò)nginx,這個(gè)小巧的東西慢慢地在吞食apache和IIS的份額。今天我們就簡(jiǎn)單介紹下本人在使用nginx的過(guò)程中的一些小小的經(jīng)驗(yàn)
    2017-10-10
  • Nginx配置防盜鏈的完整步驟

    Nginx配置防盜鏈的完整步驟

    這篇文章主要給大家介紹了關(guān)于Nginx配置防盜鏈的完整步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Nginx具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • nginx關(guān)于add_header的坑及解決

    nginx關(guān)于add_header的坑及解決

    這篇文章主要介紹了nginx關(guān)于add_header的坑及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • Nginx 中實(shí)現(xiàn)請(qǐng)求的排隊(duì)機(jī)制的過(guò)程詳解

    Nginx 中實(shí)現(xiàn)請(qǐng)求的排隊(duì)機(jī)制的過(guò)程詳解

    Nginx中的請(qǐng)求排隊(duì)機(jī)制就像是交通警察指揮交通一樣,讓網(wǎng)絡(luò)流量有序地流動(dòng),保障服務(wù)器的穩(wěn)定運(yùn)行和用戶的良好體驗(yàn),在深入探討 Nginx 中的請(qǐng)求排隊(duì)機(jī)制之前,咱們先來(lái)弄明白到底什么是請(qǐng)求的排隊(duì)機(jī)制,帶著這個(gè)問(wèn)題一起通過(guò)本文學(xué)習(xí)吧
    2024-07-07
  • nginx反向代理服務(wù)因配置文件錯(cuò)誤導(dǎo)致訪問(wèn)資源時(shí)出現(xiàn)404

    nginx反向代理服務(wù)因配置文件錯(cuò)誤導(dǎo)致訪問(wèn)資源時(shí)出現(xiàn)404

    這篇文章主要介紹了nginx反向代理服務(wù)因配置文件錯(cuò)誤導(dǎo)致訪問(wèn)資源時(shí)出現(xiàn)404,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-06-06
  • NGINX njs從基礎(chǔ)配置到高級(jí)特性實(shí)戰(zhàn)

    NGINX njs從基礎(chǔ)配置到高級(jí)特性實(shí)戰(zhàn)

    njs是NGINX推出的輕量級(jí)JavaScript子集,通過(guò) ngx_http_js_module`模塊可在NGINX中實(shí)現(xiàn) location 處理、變量定義、響應(yīng)過(guò)濾等核心能力,感興趣的可以了解一下
    2026-01-01
  • nginx通過(guò)location配置代理的原理和實(shí)現(xiàn)方式

    nginx通過(guò)location配置代理的原理和實(shí)現(xiàn)方式

    這篇文章主要介紹了nginx通過(guò)location配置代理的原理和實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • Nginx限流防刷與CC攻擊防護(hù)實(shí)戰(zhàn)配置

    Nginx限流防刷與CC攻擊防護(hù)實(shí)戰(zhàn)配置

    本文介紹了Nginx在Web服務(wù)中的防護(hù)方案,包括限流基礎(chǔ)、分場(chǎng)景限流、CC攻擊防護(hù)、IP黑白名單、監(jiān)控與告警以及壓測(cè)驗(yàn)證,感興趣的可以了解一下
    2026-01-01
  • nginx上部署react項(xiàng)目的實(shí)例方法

    nginx上部署react項(xiàng)目的實(shí)例方法

    今天小編就為大家分享一篇關(guān)于nginx上部署react項(xiàng)目的實(shí)例方法,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-02-02

最新評(píng)論

襄汾县| 通山县| 克山县| 阿瓦提县| 大冶市| 保靖县| 兰考县| 盐城市| 抚顺县| 紫云| 敦化市| 衢州市| 合作市| 陕西省| 绥江县| 雷波县| 虹口区| 贺兰县| 南召县| 新闻| 开平市| 承德县| 封开县| 永清县| 延庆县| 兴国县| 吉隆县| 西平县| 喜德县| 将乐县| 沾益县| 嘉善县| 团风县| 忻城县| 杂多县| 张家口市| 宁阳县| 嘉义市| 通化市| 池州市| 蒲江县|