nginx secondary directory

Requirement: use 80 port deployment api+web + of a server to receive GET request of wechat interface configuration information

Front end development uses JS-SDK to invoke the function of Tencent map and use it in public address.
At the time of development, there is only one Tencent cloud server. It needs to configure the interface configuration information of WeChat public number at the same time, JS interface security domain name. [see WeChat public address configuration]

nginx configuration [80 port server]:

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    #root /var/www/html;

    # Add index.php to the list if you are using PHP
    #index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # The configuration here is the request to receive the configuration information of WeChat public address interface. WeChat server needs to send HTTP GET request to the 80 port of the current server, which can only be 80 ports.
        # The backend uses the flash + uwsgi. The configuration here ensures that HTTP requests are forwarded, and the corresponding backend's flash API is available
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:5000; 
    }
    
    #location /v1/api/ {
    #    The api interface service of the project is configured here, which is combined with the location / above
    #    include uwsgi_params;
    #    uwsgi_pass 127.0.0.1:5000;
    #}    
    
    # Requirements here:
    # Visit http://IP/sites/index.html to access the index.html page normally, and ensure the api is available at the same time
    
    location /sites {
        alias /root/sites;  # Directory of web project
        index index.html;   # index.html
        try_files $uri @rewriteweb;
    }
    location @rewriteweb {
        rewrite ^/sites/(.*)$ /sites/index.html break;  # Note the break here
    }



}



Tags: Python SSL Nginx PHP SDK

Posted on Mon, 02 Dec 2019 23:28:45 -0800 by Dutch MaFia-boy