nginx跳轉至專案首頁配置

2022-09-12 16:57:35 字數 455 閱讀 2945

前言:有時候我們會有這樣乙個需求,輸入www.example.com,自動**到伺服器下的乙個專案首頁,這時候就需要如下配置

#精確匹配,只匹配www.example.com

location = /

location /

其中「item」為部署的專案名,輸入www.example.com之後,會自動跳轉http://ip:port/item/index(專案首頁)

proxy_pass http://ip:port;這一行要特別注意一下,http://ip:port和http://ip:port/是有區別的

例如:輸入www.example.com/item/test.html,前者(http://ip:port)會被**到http://ip:port/item/test.html,後者(http://ip:port/)會被**到http://ip:port/test.html

nginx配置https http跳轉至https

在配置ssl證書之前,要確保你的nginx已經安裝了ssl模組,一般情況下自己安裝的nginx都是不存在ssl模組的。這裡先檢查下自己是否存在ssl模組 進入到你的nginx安裝目錄下面,我的目錄是在 usr local nginx 如果你的nginx安裝步驟和上面的文章一致的話,那你的目錄和我應該...

nginx配置http跳轉https

基於nginx搭建了乙個https訪問的虛擬主機,監聽的網域名稱是test.com,但是很多使用者不清楚https和http的區別,會很容易敲成這時會報出404錯誤,所以我需要做基於test.com網域名稱的http向https的強制跳轉 我總結了三種方式,跟大家共享一下 這應該是大家最容易想到的方...

nginx 301 302跳轉配置總結

首先看簡單的 示例,關於nginx 301 302跳轉的。301跳轉設定 server 302跳轉設定 server 關於nginx 301 302跳轉的詳細說明文件 server last 基本上都用這個flag。break 中止rewirte,不在繼續匹配 redirect 返回臨時重定向的ht...