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

Nginx配置同時支持http和https兩種方式訪問

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

http:
nginx 同時支持http和https,java,nginx,http,https
https:

Nginx的ssl模塊安裝

進入到目錄的sbin目錄下,輸入

#注意這里是大寫的V,小寫的只顯示版本號
./nginx -V  

如果出現(xiàn) (configure arguments: --with-http_ssl_module), 則已安裝(下面的步驟可以跳過,直接進行第五步)。

一般情況下都是不存在ssl模塊的,接下來進入到你的解壓縮后的nginx目錄,注意這里不是nginx安裝目錄,是解壓縮后的目錄。

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

然后執(zhí)行

make
#切記不要執(zhí)行make install,否則會重新安裝nginx

接下來使用新的nginx文件替換掉之前安裝目錄sbin下的nginx,注意這里的替換的時候可以先將之前的文件備份下,停掉nginx服務(wù)。

./nginx -s stop #停止nginx服務(wù)

#替換之前的nginx
cp /usr/nginx/objs/nginx /usr/local/nginx/sbin

成功之后,進入到nginx安裝目錄下,查看ssl時候成功

#注意這里是大寫的V,小寫的只顯示版本號
./nginx -V  
#可以看到這里出現(xiàn)了configure arguments: --with-http_ssl_module   證明已經(jīng)安裝成功

nginx 同時支持http和https,java,nginx,http,https
nginx.conf文章來源地址http://www.zghlxwxcb.cn/news/detail-537762.html


#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  ip;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        	proxy_pass http://ip:端口/;
            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       80;
        listen       443 ssl;
        server_name  ip;
		 
		  location / {
        	proxy_pass http://ip:端口/;
        }

        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;
    #    }
    }

}

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

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

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

相關(guān)文章

  • Nginx 一個端口同時支持 http 和 https協(xié)議【詳細步驟】

    ?? 背景:使用 Nginx 1.24.0 代理前端及后端應(yīng)用,假設(shè)稱之為 A 系統(tǒng)。A 系統(tǒng)最初使用的是 http 協(xié)議,后來改成了 https 協(xié)議。 Nginx 配置 https 訪問【圖文教程】:Nginx 配置 https 訪問 ?? 問題:修改為 https 協(xié)議后,發(fā)現(xiàn)一些問題。即 依賴 A 的系統(tǒng)沒有改成 https,導(dǎo)致報錯 。 ??

    2024年01月25日
    瀏覽(25)
  • nginx支持一個端口訪問多個前端項目(http以及https)

    ????最近做項目結(jié)構(gòu)優(yōu)化,前端項目都是部署在nginx上,想實現(xiàn)同一個端口可以訪問多個前端項目.這樣可以提高服務(wù)器的端口復(fù)用率,降低項目部署以及維護成本.根據(jù)平常的需求,用兩臺nginx服務(wù)器分別支持http、https同一端口訪問不同項目。下面將配置方式以及相關(guān)注意事項做簡

    2024年02月03日
    瀏覽(33)
  • nginx 同一個端口支持http和https配置

    原理:使用nginx的stream、 stream_ssl_preread模塊 1.編譯nginx 由于stream和stream_ssl_preread模塊非默認引入,需要在編譯安裝nginx時引入;編譯時添加配置參數(shù) --with-stream --with-stream_ssl_preread_module ./configure --prefix=/usr/local/nginx?--with-http_ssl_module --with-http_stub_status_module --with-stream --with-stre

    2024年02月10日
    瀏覽(20)
  • nginx的同一個端口配置支持http與https協(xié)議

    http://www.baidu.com:5000 https://www.baidu.com:5000 請求自定義端口的http 跟https,都一樣的頁面 vim /opt/lucky/nginx/conf/vhosts/baidu.conf

    2024年02月13日
    瀏覽(88)
  • Nginx配置https網(wǎng)站訪問第三方節(jié)點的http資源

    https網(wǎng)站無法直接下載http網(wǎng)站的文件。解決思路有以下幾種情況:1.兩個網(wǎng)站都同時改為http或https。2.通過nginx轉(zhuǎn)發(fā)。3.通過后端java代碼獲取對方網(wǎng)站的文件流然后把流返回給前端 本文介紹如果通過nginx轉(zhuǎn)發(fā)訪問http網(wǎng)站 配置規(guī)則一: 這樣配置之后,本地網(wǎng)站比如是:訪問htt

    2024年02月16日
    瀏覽(26)
  • kubernetes的ingress實現(xiàn)同時支持http和https

    生產(chǎn)環(huán)境中對外的服務(wù)一般需要配置https服務(wù),使用ingress也可以很方面的添加https的證書。默認情況下,如果為該 Ingress 啟用了 TLS,控制器會使用 308 永久重定向響應(yīng)將 HTTP 客戶端重定向到 HTTPS 端口 443。( Ingress 里配置了 https 證書的話,默認就一定會走 https)。即默認情況

    2024年02月15日
    瀏覽(20)
  • SpringBoot + Vue2項目打包部署到服務(wù)器后,使用Nginx配置SSL證書,配置訪問HTTP協(xié)議轉(zhuǎn)HTTPS協(xié)議

    SpringBoot + Vue2項目打包部署到服務(wù)器后,使用Nginx配置SSL證書,配置訪問HTTP協(xié)議轉(zhuǎn)HTTPS協(xié)議

    配置nginx.conf文件,這個文件一般在/etc/nginx/...中,由于每個人的體質(zhì)不一樣,也有可能在別的路徑里,自己找找... 證書存放位置,可自定義存放位置 兩個文件 后端配置 把.pfx拷貝到resource下,然后配置一下yml

    2024年02月02日
    瀏覽(100)
  • 虛擬機上用docker + nginx跑前端并支持https和http

    虛擬機上用docker + nginx跑前端并支持https和http

    情況是這樣,我在虛擬機上,使用docker跑前端,需要這個前端支持https,原h(huán)ttp的話自動跳轉(zhuǎn)到https。另外,前端部署使用了負載均衡,即使用了3個docker跑前端:1個入口,另外2個是前端,指向了同一份網(wǎng)站代碼。(有關(guān)前端部署負載均衡,詳見拙作《使用docker部署多個nginx站點

    2024年02月12日
    瀏覽(21)
  • nginx配置https訪問

    為什么需要使用HTTPS,因為HTTP不安全,當使用http進行消息傳輸時,可能會遭到黑客的劫持和篡改,如果采用https協(xié)議,那么數(shù)據(jù)在傳輸過程中是加密的,所以黑客無法竊取或者篡改數(shù)據(jù)報文信息,同時也避免網(wǎng)站傳輸時信息泄露。 實現(xiàn)https:需要使用ssl協(xié)議。 首先需要申請證

    2024年01月22日
    瀏覽(17)
  • Linux配置Nginx SSL支持Https配置教程

    Linux配置Nginx SSL支持Https配置教程

    繼承上篇 Linux安裝Nginx 執(zhí)行: ./nginx -V 命令 如果有輸出 --–with-http_ssl_module 則說明已安裝好SSL模塊 進入安裝目錄 /usr/local/nginx-1.22.1 執(zhí)行安裝命令: ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 執(zhí)行編譯命令: make 注意:make成功后不要執(zhí)行 make insta

    2024年01月18日
    瀏覽(26)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包