Nginx reverse proxy - forwarding port forwarding and directory

A configuration

nginx.conf introduced include vhost / * conf;. profile
creation vhost / port.conf file in the same directory nginx.conf

Second, port forwarding

server {
    listen 80;
    autoindex on;
    server_name www.port.com;
    access_log c:/access.log combined;
    index index.html index.htm index.jsp index.php;
    #error_page 404 /404.html;
    if ( $query_string ~* ".*[\;'\<\>].*" ) {
        return 404;
    }

    location / {
        proxy_pass http://127.0.0.1:8080;
        add_header Access-COntrol-Allow-Origin *;
    }
}

Configuring hosts
127.0.0.1 www.port.com
restart Nginx
niginx -s reload
http://127.0.0.1:8080 port is tomcat server configuration
which would be forwarded to the tomcat server when it entered www.port.com

Second, file transfer

server {
    listen 80;
    autoindex on;
    server_name www.file.com;
    access_log c:/access.log combined;
    index index.html index.htm index.jsp index.php;
    #error_page 404 /404.html;
    if ( $query_string ~* ".*[\;'\<\>].*" ) {
        return 404;
    }

    location / {
        root C:\file\img; # \是Windows /是Linux
        add_header Access-Control-Allow-Origin *;
    }
}

Configuring hosts
127.0.0.1 www.file.com
restart Nginx
niginx -s reload
access www.file.com you can see the C: Pictures \ in the file \ img.

Guess you like

Origin www.cnblogs.com/greycdoer0/p/11817274.html