nginx配置反向代理

匆匆过客 提交于 2020-02-13 23:42:19

nginx配置反向代理

# 运行用户
user  nginx;
# 工作者进程
worker_processes  1;

## 日志
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


## 工作模式和连接数上限
events {
    worker_connections  1024;
}

# 设定http服务器
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

#    include /etc/nginx/conf.d/*.conf;

server {
    listen       80;
    server_name  .a.com;

    charset utf-8;
    access_log  /var/log/a.com.access.log;

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:9080;
    }
}

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!