Web Nginx为url设置ssl

Web Nginx为url设置ssl,web,https,nginx,admin,Web,Https,Nginx,Admin,你好。我得到了nginx服务器,它运行https连接。 目前,所有URL都使用https运行。我所需要的就是——从https中排除一些URL,这样就可以用简单的http访问它们。 这是我的NGINX配置文件: server { listen 80; server_name my-fin.ru www.my-fin.ru; root /usr/server/finance/abacus/we

你好。我得到了nginx服务器,它运行https连接。 目前,所有URL都使用https运行。我所需要的就是——从https中排除一些URL,这样就可以用简单的http访问它们。 这是我的NGINX配置文件:

server {
       listen           80;
       server_name              my-fin.ru www.my-fin.ru;

        root         /usr/server/finance/abacus/webapp;

        location ~ ^/.+\.(eot|ttf|woff)$ {
            expires max;
            add_header Cache-Control public;
            add_header Access-Control-Allow-Origin *;
        }

        location ~ ^/.+\.(ico|jpg|jpeg|gif|pdf|jar|png|js|css|txt|epf|svg)$ {
            expires max;
            add_header Cache-Control public;
        }

        location / {
               return                   301 https://my-fin.ru;
        }

}

server {
        listen          *:443;
        server_name     my-fin.ru;
        client_max_body_size 10m;
        gzip                    on;
        gzip_min_length 500;
        gzip_buffers    4 8k;
        gzip_types              text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json application/json;

        access_log  /var/log/nginx/finance.access.log;
        error_log   /var/log/nginx/finance.error.log;

        ssl on;
        ssl_certificate         /usr/server/myfin.crt;
        ssl_certificate_key     /usr/server/myfin.key;
        charset                 utf-8;

        root         /usr/server/finance/abacus/webapp;

        location ~ ^/.+\.(eot|ttf|woff)$ {
            expires max;
            add_header Cache-Control public;
            add_header Access-Control-Allow-Origin *;
        }

        location ~ ^/.+\.(ico|jpg|jpeg|gif|pdf|jar|png|js|css|txt|epf|svg)$ {
            expires max;
            add_header Cache-Control public;
        }

        location / {
                # give site more time to respond
                proxy_read_timeout 120;
                proxy_pass        http://127.0.0.1:8087;
                proxy_redirect          http:// $scheme://;

                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr ;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
        }

}
请帮助配置nginx。

根据,以下是我将如何进行配置

## non https server
server {
    #non ssl server
    listen 80;
    server_name example.com;
    root /path/to/root;
    location /features {
        #handle /features
    }
    location /info {
        # handle /info
    }
    location /help {
        #handle /help
    }
    location /
        return 301 https://example.com$request_uri;
    }
}
## https server
server {
    # handle ssl
    listen 443 ssl;
    server_name example.com subdomain1.example.com;
    root /path/to/root;
    location ~ /(features|help|info) {
        # redirect those 3 subfolders to http
        return 301 http://example.com$request_uri;
    }
    location / {
        #handle ssl requests;
    }
}
## https subdomain
server {
    listen 443 ssl;
    server_name subdomain2.example.com;
    root /path/to/root;
    location ~ /(features|help|info) {
        # redirect those 3 subfolders to http
        return 301 http://example.com$request_uri;
    }
    location / {
        # subdomain handling
    }
}

请注意,除非您具有通配符SSL证书,否则https将无法在子域上工作,否则浏览器将发出警告。

因此,如果某些URL被SSL访问,您希望将其重定向到非SSL正确吗?没错。我需要它。好的,哪个URL应该是非SSL的?**我还有一个web应用程序在8087端口本地运行,还有一个应用程序在8088端口本地运行。我需要第二个(8088)在https下运行,并通过子域**ablo。谢谢。它似乎起作用了。你能帮我完成其他任务(另一个注释)吗,这样我就可以处理子域请求了。如果子域有任何不同的配置,你总是可以为它创建另一个服务器块,否则就将它添加到
服务器名称中,用空格分隔,我将编辑我的答案,告诉你如何操作。