[Nginx] solution: it can’t be accessed on the background API interface after HTTPS (access the specified port through the domain name)


Original address: http://ip :54774/api_ Name
now requires you to access the specified port through the domain name: https://api.example.com/api_ name

The most important thing is to configure the reverse proxy address of location

When we enter the domain name/API_ Name
will be mapped by nginx to IP or domain name: 54774/API_ Name path go to the nginx directory, open nginx. Conf , add reverse proxy :

    listen 80;
	listen 443 ssl http2;
    server_name https://api.example.com;
    # Reverse Proxy
    location ~ ^/api_name {
        proxy_pass http://ip:54777;
    #SSL-START SSL-related configuration, please do not delete or modify the next line with the comment 404 rules
    #error_page 404/404.html;
    ssl_certificate    /www/server/panel/vhost/cert/api.example.com/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/api.example.com/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;

    #ERROR-PAGE-START  Error page configuration, which can be commented, deleted or modified
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    #PHP-INFO-START  PHP reference configuration, can be commented or modified
    #include enable-php-72.conf;
    #REWRITE-START URL rewrite rule reference, the modification will cause the panel to set the pseudo-static rules are invalid
    #include /www/server/panel/vhost/rewrite/api.example.com.conf;
    #Files or directories to which access is prohibited
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
        return 404;
    #One Click Application for SSL Certificate Verification Directory Related Settings
    location ~ \.well-known{
        allow all;
    1. overload configuration file:
./nginx -s reload

Read More: