nginx configures http to force jump to https

    # 301重定向, 访问http跳转到https
    server {
        listen 80;
        server_name chat.xutongbao.top;
        return 301 https://chat.xutongbao.top;
    }    

    server {
        listen       443 ssl; 
        server_name  chat.xutongbao.top;
        ssl_certificate         /temp/ssl/chat.xutongbao.top/chat.xutongbao.top.crt;   # nginx的ssl证书文件
        ssl_certificate_key     /temp/ssl/chat.xutongbao.top/chat.xutongbao.top.key;  # nginx的ssl证书验证密码

        #配置根目录
        location / {
            root    /temp/yuying;
            index  index.html index.htm;
            add_header Content-Security-Policy upgrade-insecure-requests;

        }

        location /api/ {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://yuying-api.xutongbao.top;
        }

        # 匹配sslCnd开头的请求,实际转发的请求去掉多余的sslCnd这三个字母
        location ^~/sslCnd/ {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://cdn.xutongbao.top/;
        }           
    }      

1. What is Nginx?

Nginx is a high-performance HTTP and reverse proxy web server that also provides IMAP/POP3/SMTP services. Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3/SMTP) proxy server. The characteristics of Nginx are: it occupies less memory and has strong concurrency capability.

Nginx is specially developed for performance optimization. Performance is the most important consideration. It pays great attention to efficiency. In fact, the concurrency capability of Nginx is better than other web servers of the same type, and it can support up to 50,000 concurrent connection responses.

Concept: The reverse proxy server is located between the user and the target server, but for the user, the reverse proxy server is equivalent to the target server, that is, the user can directly access the reverse proxy server to obtain the resources of the target server.

The reverse proxy, in fact, is unaware of the proxy for the client, because the client can access it without any configuration.

Process: In reverse proxy, we only need to send the request to the reverse proxy server. After the reverse proxy server selects the target server to obtain the data, it returns the data to the client. At this time, the reverse proxy server and the target server are in the outside world. It seems that it is a server, and what is exposed is a proxy server, which hides the IP address of the real server.

Reference link:
https://chat.xutongbao.top/
 

Guess you like

Origin blog.csdn.net/xutongbao/article/details/131741812