Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
页面不是’;升级到Nginx 1.17后是否正确重定向?_Nginx - Fatal编程技术网

页面不是’;升级到Nginx 1.17后是否正确重定向?

页面不是’;升级到Nginx 1.17后是否正确重定向?,nginx,Nginx,首先,我的nginx1.14配置工作正常。升级到nginx主线1.17后,我的nginx停止工作。我的default.conf如下所示。知道从那以后发生了什么变化吗?我应该在哪里查看并更正我的nginx默认配置 其次,除了mobile.mysite.com/admin1、admin2、admin3、admin4之外的任何内容都必须重定向到默认的index.html文件。但我也不能补充。有什么想法吗 更新-1: mobile.mysite.com/admin1看起来正常,但mobile.mysit

首先,我的nginx1.14配置工作正常。升级到nginx主线1.17后,我的nginx停止工作。我的default.conf如下所示。知道从那以后发生了什么变化吗?我应该在哪里查看并更正我的nginx默认配置

其次,除了
mobile.mysite.com/admin1
admin2
admin3
admin4
之外的任何内容都必须重定向到默认的
index.html
文件。但我也不能补充。有什么想法吗

更新-1: mobile.mysite.com/admin1看起来正常,但mobile.mysite.com/admin1/*****或mobile.mysite.com/admin1/******/*****未重定向。。。有什么想法吗

更新-2: 当我键入h#ps://mobile.mysite.com/admin1/KH/login

它在地址栏上显示为 h#ps://mobile.mysite.com/admin1/KH/index.html

server {
    charset UTF-8;
    listen 80;
    listen [::]:80;
    server_name  mobile.mysite.com;

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

    location = / {
        root /usr/share/nginx/html;
        index index.html index.htm;
    }

    # redirect error pages to the static page
    error_page 401 402 403 404 405 500 502 503 504 index.html;
    location = /index.html {
        root /usr/share/nginx/html;
        internal;
    }

    # Deny access to .htaccess files
    location ~ /\.ht {
        deny  all;
    }

    # Deny access to hidden files (beginning with a period)
    location ~ /\. {
         deny all;
    }


    if ($host = mobile.mysite.com/admin1) {
        return 301 https://$host$request_uri;
    } 


    if ($host = mobile.mysite.com/admin2) {
        return 301 https://$host$request_uri;
    } 


    if ($host = mobile.mysite.com/admin3) {
        return 301 https://$host$request_uri;
    } 


    if ($host = mobile.mysite.com/admin4) {
        return 301 https://$host$request_uri;
    } 

}


server {
    charset UTF-8;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot
    server_name  mobile.mysite.com;

    ssl_certificate /etc/letsencrypt/live/mobile.mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mobile.mysite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

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

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    # redirect admin1
    location /admin1 {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.101:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }


    # redirect admin2
    location /admin2 {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.102:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }


    # redirect admin3
    location /admin3 {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.103:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }


    # redirect admin4
    location /admin4 {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.104:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }


    # redirect error pages to the static page
    error_page 401 402 403 404 405 500 502 503 504 index.html;
    location = /index.html {
        root /usr/share/nginx/html;
        internal;
    }


    # deny access to .htaccess files
    location ~ /\.ht {
        deny  all;
    }

    # Deny access to hidden files (beginning with a period)
    location ~ /\. {
         deny all;
    }

    if ($request_method !~ ^(GET|HEAD|POST)$ )
    {
         return 404;
    }

}

在h##ps://community.letsencrypt.org/t/the-page-is-t-redirecting-property-after-upgrade-to-1-17/109196/7上的@rg305的帮助下,它刚刚完成并开始工作。我使用的是conf.d/default.conf,没有使用站点启用或站点可用文件夹。以下是我添加和工作的内容。我制作了更简单的80服务器,如下所示。然后我又加了一句

proxy_http_version  1.1;
proxy_cache_bypass  $http_upgrade;
proxy_set_header Upgrade    $http_upgrade;
proxy_set_header Connection     "upgrade";
对于每一个应用和它的工作甚至比以前更好。如果我键入admin1,或admin1/****proxy\u pass正在工作。除了admin1或admin1/****重定向到索引html文件之外的任何内容

添加标题X-Frame-Options SAMEORIGIN; 添加标题X-Content-Type-Options-nosniff; 添加_头X-XSS-Protection“1;模式=块”

server {
    charset UTF-8;
    listen      80;
    listen [::]:80;
    server_name  mobile.mysite.com;

    # HTTP REDIRECT
    location / {
    return 301 https://mobile.mysite.com$request_uri;
    }

}


server {
    charset UTF-8;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot

    server_name  mobile.mysite.com;
    root /var/www/html/;

    # SSL
    ssl_certificate /etc/letsencrypt/live/mobile.mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mobile.mysite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    # LOGING    
    access_log  /var/log/nginx/host.access.log  main;
    error_log  /var/log/nginx/host.error.log  warn;

    # index.html fallback
    location / {
    try_files $uri $uri/ /index.html;
    }

    # reverse proxy admin1
    location /admin1 {
        proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;
    proxy_set_header Upgrade    $http_upgrade;
    proxy_set_header Connection     "upgrade";
    proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.101:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }

    # reverse proxy admin2
    location /admin2 {
        proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;
    proxy_set_header Upgrade    $http_upgrade;
    proxy_set_header Connection     "upgrade";
    proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.102:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }

    # reverse proxy admin3
    location /admin3 {
        proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;
    proxy_set_header Upgrade    $http_upgrade;
    proxy_set_header Connection     "upgrade";
    proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.103:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }

    # reverse proxy admin4
    location /admin4 {
        proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;
    proxy_set_header Upgrade    $http_upgrade;
    proxy_set_header Connection     "upgrade";
    proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass "http://192.168.1.104:3000/";
        proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
        proxy_intercept_errors on;
    }




    # redirect error pages to the static page
    error_page 401 402 403 404 405 index.html;
    location = /index.htm {
        root /usr/share/nginx/html;
        internal;
    }


    # redirect server error pages to the static page
    error_page 500 502 503 504 index.html;
    location = /50x.html {
        root /usr/share/nginx/html;
        internal;
    }


    # deny access to .htaccess files
    location ~ /\.ht {
        deny  all;
    }

    # Deny access to hidden files (beginning with a period)
    location ~ /\. {
         deny all;
    }

    if ($request_method !~ ^(GET|HEAD|POST)$ )
    {
         return 404;
    }

}