網站首頁 編程語言 正文
nginx 反向代理以及 location /admin/
反向代理時,
需要特別注意
,本地測試時確保類似IP調用
127.0.0.1:8082/admin 這種情況可以直接訪問,在做反向代理。否則請使用測試域名訪問,反向代理才可以成功,最好設置相關header頭,跳轉的才可以使用。
// 常規
server {
listen 8280;
server_name angelsteward.test *.angelsteward.test;
root "E:/own/git/angelsteward/public/";
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
autoindex on;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass php_upstream;
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
charset utf-8;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\.ht {
deny all;
}
}
// 反向代理
server {
listen 8280;
server_name angelsteward.test *.angelsteward.test;
location / {
root "C:\Users\Y\Desktop\18token\18token.im";
index index.html index.htm index.php;
autoindex on;
}
location /admin {
#alias "E:/own/git/cim/public/";
proxy_pass http://127.0.0.1:8082;
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_set_header X-NginX-Proxy true;
#try_files $uri $uri/ /index.php$is_args$args;
#index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php(.*)$ {
include snippets/fastcgi-php.conf;
fastcgi_pass php_upstream;
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
charset utf-8;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\.ht {
deny all;
}
}
// ssh 443 https
server {
listen 4430 ssl;
# listen 443;
server_name angelsteward.test *.angelsteward.test;
# ssl on;
ssl_certificate E:\own\git\https\server.pem;
ssl_certificate_key E:\own\git\https\privkey.pem;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
root "E:/own/git/angelsteward/public/";
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
autoindex on;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass php_upstream;
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
charset utf-8;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\.ht {
deny all;
}
}
# This file is auto-generated.
# If you want Laragon to respect your changes, just remove the [auto.] prefix
# If you want to use SSL, enable it at: Menu > Nginx > SSL > Enabled
重點
alias 關鍵字,在此處是通過 / 根目錄訪問靜態網頁。/admin 訪問 php 項目,此處由于原 laravel 項目域名路由已經定義 admin 路徑沖突,只能使用反向代理配置。
這種情況應該是適用于 php 項目已有 /admin 子目錄時且已經是適配 /admin 的路由,或者是類似 /api 的路由配置,才可以進行目錄跳轉適配。否則產生錯誤404。
即反向代理用戶多個不同的項目部署于一個域名下。
alias 用于項目(多個)下的多個模塊區分,比如 前后端、api 分離 的路由指定。
在做 https ssh 443 的配置時,暫可以忽略其他配置。
原文鏈接:https://blog.csdn.net/weixin_43930641/article/details/123066255
相關推薦
- 2022-07-28 Redis特殊數據類型HyperLogLog基數統計算法講解_Redis
- 2022-05-15 Docker基本概念和底層原理解析_docker
- 2023-11-12 python enumerate函數用法
- 2022-04-16 WPF創建Prism應用程序_實用技巧
- 2023-08-13 為什么Git需要配置ssh密鑰,怎么配置?
- 2022-12-03 pytorch模型保存與加載中的一些問題實戰記錄_python
- 2022-06-01 Android利用MediaRecorder實現錄音功能_Android
- 2024-04-02 VsCode中修改/重置git遠程倉庫地址(與拉去遠程項目)
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支