【Nginx重定向到外部URL】教程文章相关的互联网学习教程文章

将nginx错误重定向到php【代码】

我的目标是将nginx中的任何错误(即404,405等…)重定向到位于index.php的我的php脚本.`server {root /usr/share/nginx/TradeLog/www/;index index.php index.html index.htm default.html default.htm;# Make site accessible from http://localhost/server_name localhost;server_name_in_redirect off;fastcgi_intercept_errors on;error_page 403 404 /index.php/;location / {try_files $uri $uri/ /index.php?$args;}location ...

url – Nginx merge_slashes重定向【代码】

我在我的Java应用程序中使用nginx,我的问题是nginx正在合并斜杠,我无法将我的网站重定向到正确的版本. 例如:http://goout.cz/cs/koncerty///praha/被合并到http://goout.cz/cs/koncerty/praha/然后我无法识别格式错误的URL并执行重定向. 我试着设定merge_slashes off;然后:rewrite (.*)//(.*) $1/$2 permanent;但是这没有效果,并且//保留在URL中. 我怎样才能做到这一点?解决方法:试试这个(未经测试):merge_slashes off; rewrit...

nginx重定向到docker容器【代码】

在发布我的问题之前,我想知道是否有可能实现我想要的. 我有,比方说,myserver.com使用nginx&运行一个docker容器. letsencrypt.在同一台服务器上还有2个运行网站的docker容器. 现在所有的都被重定向好了,所以www.myserver.com去了docker 1而site2.myserver.com去了docker 2. 我希望通过HTTPS运行所有通信,但这里开始麻烦.所以,我的问题是:使用来自letsencrypt的证书,使用nginx和letsencrypt的docker是否可以连接到另一个docker?对我...

重定向 – 子域的Nginx变量?【代码】

我需要一个Guru的建议. 在Nginx的conf文件中,我想将子域作为变量,以便重定向访问,如下所示. >访问:http://userX.example.com/?hoo = bar> REDIRECT:http://example.com/userX/?hoo = bar 但我明白了 > REDIRECT:http://example.com/userX.example.com/?hoo = bar 我当前的_http.conf设置如下所示.所以很明显它是有效的.## default HTTP server {listen 80;server_name default_server;return 301 http://exa...

Nginx子域重定向到静态URL【代码】

我有一个域名,我可以通过example.com:1234浏览.现在我不想总是在最后输入端口,而是在浏览子域时让nginx将我重定向到静态URL,例如. status.example.com. 我尝试过编写重定向,但它根本不起作用.server {listen 80;server_name status.example.com;return 301 $scheme://www.example.com:1234; }哪里是我的错误?它是服务器块吗?我错过了一些基本的东西吗?解决方法:请尝试配置如下,server {listen 80;server_name status.example.co...

Nginx重定向到www域无法正常工作【代码】

我有以下nginx配置.server {listen 80;listen [::]:80;listen 443 ssl;server_name example.com;return 301 https://www.example.com$request_uri; }>它将http://example.com重定向到https://www.example.com>但不会将https://example.com重定向到https://www.example.com. 如何将https://example.com重定向到https://www.example.com?解决方法:请分开http和https流量.你当前的配置搞砸了一些东西.以下代码使用永久重定向重写从ht...

internet-explorer – 使用nginx将旧的IE用户重定向到不同的URL【代码】

我可以通过在我的服务器块中使用以下代码段为旧IE用户提供过时的浏览器页面:location / {if ($http_user_agent ~ "MSIE 8.0") {rewrite ^ /ie.html break;} }这工作正常,nginx为IE 8用户提供ie.html.不过,我有两个问题. 一个是我想将旧的IE用户重定向到/ upgradebrowser而不是仅仅为它们提供HTML页面.有没有办法可以发送位置:标题或其他什么? 第二,有什么方法可以让我轻松捕获IE的所有老用户?目前这只是在做IE 8.0,有没有办法使...

为什么我的Nginx反向代理node.js表示服务器重定向到0.0.0.0?【代码】

我有一台服务器配置为托管多个node.js通过Ngnix前端在多个域上表达应用程序.一切都很好,除了从快速路线调用重定向时:res.redirect('/admin');然后客户端浏览器重定向到http://0.0.0.0:8090 似乎问题一直是来自express的重定向头的问题,但是为了防止相关,这里是相关域的nginx.conf文件:server {listen 0.0.0.0:80;server_name *.example.com;access_log /var/log/nginx_example_access.log;error_log /var/log/nginx_example_e...

web-applications – 如何使用位置正则表达式通过nginx重定向/处理来自搜索引擎的请求【代码】

我开发了一个基于ajax的web应用程序,带有哈希爆炸网址. 我试图将请求从搜索引擎重定向到另一个生成HTML快照并发送响应的服务器.我试图在nginx中使用location指令实现这一点,如下所述:location ~ ^(/?_escaped_fragment_=).*${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-Forwarded-Proto...

使用nginx重定向中的破折号替换未知子域中的下划线【代码】

我有网址进来,看起来像这样:https://some_sub_domain.whatever.com这需要重定向到:https://some-sub-domain.whatever.com我不知道子域名是什么(他们是用户名). 虽然我需要替换子域的下划线,但我需要留下其他下划线:https://some_sub_domain.whatever.com/hey_there_underscore应重定向到:https://some-sub-domain.whatever.com/hey_there_underscore解决方法:这是一种通过lua重写的方法:location / {rewrite_by_lua 'if strin...

php – nginx – 重写或内部重定向循环,同时内部重定向到“/index.html”【代码】

我无法弄清楚为什么会发生这种错误:“内部重定向到”/index.html“时重写或内部重定向循环” 我找到了similar post并根据我读到的内容尝试了各种建议,但无济于事. 这是我的nginx配置.任何帮助,将不胜感激!server {listen 80 default_server;listen [::]:80 default_server ipv6only=on;root /usr/share/nginx/html/public;index index.php;# Make site accessible from http://localhost/server_name ourdomain.com;location @ha...

使用Nginx作为代理服务器时,如何正确处理重定向响应,django作为后端【代码】

我有一个Django应用程序,最近我需要推出测试版.我希望保持当前正在运行的应用程序保持不变,并在Nginx的帮助下将所有请求以“/ beta”重定向到beta应用程序.这是我的conflocation / {proxy_pass_header Server;proxy_set_header Host $http_host;proxy_redirect off;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Scheme $scheme;proxy_connect_timeout 10;proxy_read_timeout 360;proxy_pass http://localhost:8000...

记一次nginx强制将https请求重定向http【图】

公司要做小程序,但是发现小程序只允许https请求 所以查了查资料使用nginx重定向请求得方式做 以下是过程: 阿里云ssl证书管理控制台申请ssl证书 下载nginx 证书: 解压后得到后缀为key和pem 文件,把文件放在nginx根目录,我这里得目录是 etc/nginx 修改nginx.config文件 启用443端口监听 重启nginx服务 通过https请求调用接口成功 通过http请求调用接口成功

常用nginx rewrite重定向-跳转实例

1,将www.myweb.com/connect 跳转到connect.myweb.com rewrite ^/connect$ http://connect.myweb.com permanent; rewrite ^/connect/(.*)$ http://connect.myweb.com/$1 permanent; 2,将connect.myweb.com 301跳转到www.myweb.com/connect/ if ($host = "connect.myweb.com"){ rewrite ^/(.*)$ http://www.myweb.com/connect/$1 permanent; } 3,myweb.com 跳转到www.myweb.com if ($host != www.myweb.com ) { rewrite...

nginx 配置https 并解决重定向后https协议变成了http的问题【代码】

nginx 配置https 并解决重定向后https协议变成了http的问题 配置如下: server { listen 80; server_name localhost;return 301 https://localhost$request_uri; charset UTF-8; location / { root html; # 这个是指定一个项目所在目录 index index.html index.htm; # 这个是指定首页的文件名 } } server { listen 80 default backlog=2048; listen 443 ssl; server_name localhost; ss...