Nginx教程

Nginx配置go.conf

本文主要是介绍Nginx配置go.conf,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Nginx配置go.conf,Go是后台利用nohup后台执行的,需要nginx配置后台backend 和相应的端口

server {
    listen       80;
    server_name  gopub.tomcat97.cn;

    charset utf-8;
    access_log  /mnt/logs/www/gopub.tomcat97.cn.log;

    location /(css|js|fonts|img)/ {
        access_log off;
        expires 1d;

        root "/path/to/app_b/static";
        try_files $uri @backend;
    }

    location / {
        try_files /_not_exists_ @backend;
    }

    location @backend {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $http_host;

        proxy_pass http://127.0.0.1:8000;
    }
}

server {
    listen       80;
    server_name  upload.tomcat97.cn;

    charset utf-8;
    access_log  /mnt/logs/www/upload.tomcat97.cn.log;

    location /(css|js|fonts|img)/ {
        access_log off;
        expires 1d;

        root "/path/to/app_b/static";
        try_files $uri @backend;
    }

    location / {
        try_files /_not_exists_ @backend;
    }

    location @backend {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $http_host;

        proxy_pass http://127.0.0.1:8001;
    }
}

server {
    listen       80;
    server_name  gorpcx.tomcat97.cn;

    charset utf-8;
    access_log  /mnt/logs/www/gorpcx.tomcat97.cn.log;

    location /(css|js|fonts|img)/ {
        access_log off;
        expires 1d;

        root "/path/to/app_b/static";
        try_files $uri @backend;
    }

    location / {
        try_files /_not_exists_ @backend;
    }

    location @backend {
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $http_host;

        proxy_pass http://127.0.0.1:8002;
    }
}
这篇关于Nginx配置go.conf的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!