Nginx Windows搭建網域名稱訪問環境

2021-10-06 15:29:49 字數 1512 閱讀 5056

【筆記於學習尚矽谷課程所作】

0.nginx配置檔案的介紹

1.進入c:\windows\system32\drivers\etc\hosts,新增

192.168.196.128 gulimall.com
2.在虛擬機器環境下進入/mydata/nginx/conf,編輯nginx.conf

#在最後(include /etc/nginx/conf.d/*.conf;之前)

#加入上游伺服器

upstream gulimall

3.在虛擬機器環境下進入/mydata/nginx/conf/conf.d資料夾

cd /mydata/nginx/conf/conf.d

#拷貝乙份conf並進行修改

cp default.conf gulimall.conf

vim gulimall.conf

4.修改內容如下

server_name  gulimall.com;

#charset koi8-r;

#access_log /var/log/nginx/log/host.access.log main;

location /

5.在閘道器專案的yml配置檔案增加對映規則

#加在最後-id

: gulimall_host_route

uri: lb://gulimall-product

predicates

:- host=**.gulimall.com,gulimall.com

6.網域名稱對映效果

nginx直接**給閘道器,閘道器判斷

以後將所有專案的靜態資源都應該放在nginx裡面

規則:/static/**所有請求都由nginx直接返回

步驟:在nginx/html路徑下,建立static資料夾

將專案中static資料夾下的index整體放入nginx建立的static資料夾

刪除專案中的static資料夾

更改專案中index.html中的路徑,都加上/static/

在/mydata/nginx/conf/conf.d/gulimall.conf中增加

#增加在location之前

location /static/

Nginx Windows搭建網域名稱訪問環境

方法一 修改c windows system32 drivers etc hosts檔案,新增網域名稱和ip對映規則 方法二 使用switchhosts等軟體進行修改,在本地方案中新增網域名稱和ip對映規則 ip為nginx所在主機ip 192.168.www.1.com 192.168.www.2...

Nginx windows安裝服務

建立nginx service.exe.config 為支援net 4.0 runtime,預設只支援net 2.0 runtime 檔案結構如下 nginx service.xml 內容如下 nginx nginx service high performance nginx service d ...

域環境搭建

準備工作 windows server 2012 r2 192.168.3.120 windows server 2008 r2 192.168.3.138 windows 10 192.168.3.142 配置server2012網路 修改ip,這裡改位址具體看虛擬機器分的是哪個c段,我這裡是19...