Nginx實戰之網域名稱重定向到指定伺服器端口

2021-09-02 13:27:24 字數 796 閱讀 7796

1.場景:

通過test.open.com訪問81伺服器指定的8081埠

2.應用:

2.1首先是在雲伺服器(這裡用了阿里雲)去配置乙個test.open.cn的網域名稱;

2.2在81這台伺服器安裝nginx,並在nginx.conf進行配置,配置例項如下:

access_log  /web/logs/access.log  main;

sendfile on;

#tcp_nopush on;

upstream tomcat_server

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server

# redirect server error pages to the static page /50x.html

#error_page 500 502 503 504 /50x.html;

location = /50x.html

解釋下:當傳送http請求首先是根據網域名稱test.open.cn定位到***.xx.***.81這台伺服器,然後在這台伺服器上安裝了nginx,並對80埠進行了監聽(上面高亮字),當網域名稱為test.open.cn的請求到來的時候,就會

將改請求定位到location,而location裡的屬性proxy_pass,有tomcat_server(上面upstream定位為***.xx.***.81),最後就是轉化為http:***.xx.***.81這個請求了。

Nginx 重定向時獲取網域名稱

如果你在處理 nginx 重定向時要獲取原請求的網域名稱 比如 http 到 https 請用 host而不是 server name。從 http 的 sub2 子網域名稱跳轉到 https 的 sub1 子網域名稱 我用的 nginx 當初為了讓 http 請求跳轉到同名的 https 請求,配...

IIS URL Rewrite 重定向網域名稱到www

引入url rewrite module的最初目的是將使用者友好的url對映到asp.net或php頁面上,而url rewrite module 2.0則對另一方面進行了加強。現在我們可以在響應到達使用者瀏覽器前對應用自動生成的url進行重寫了。iis url rewrite rewriting ...

nginx網域名稱重定向遇到的問題

應客戶要求,需要給客戶配個網域名稱,然後我們的大牛強哥 建議後台不要配備網域名稱伺服器了,這樣不安全,一般都是對外的web伺服器才配置網域名稱 結合另外收藏的乙個博文安裝nginx,然後修改配置檔案如下 乙個網域名稱對應乙個conf檔案 server location share location ...