nginx --反向代理配置文件

摘要:
*****************************************************************************注意:审核过程将报告您的每一项操作!
配置文件如下图
 
server {
    listen       8080;
    server_name  0.0.0.0;//这里可以配置相应域名
    root /www/facei;
    index index.html index.htm;

    access_log  /var/log/nginx/facei.access.log;
    error_log  /var/log/nginx/facei.error.log;

    location / {
        try_files $uri $uri /index.html =404;
    }

    location ~ /(oauth|rest)/ {
        proxy_pass https://aip.baidubce.com;//反向代理配置
    }
}

nginx --反向代理配置文件第1张

nginx 配置文件在centos上的路径是

/etc/nginx/conf.d/文件夹是其他站点的配置文件

 

/etc/nginx/nginx.conf  是配置文件

一般主配置都在nginx.conf里面,站点的配置都会放在conf.d里面。

 

下图是其他服务器的配置文件,待后续研究

user  sasuke;
worker_processes  2;

error_log  /home/sasuke/app/log/error.log;
pid        /home/sasuke/app/log/nginx.pid;
worker_rlimit_nofile 65535;


events {
    use epoll;
    worker_connections 1024;
    accept_mutex on;
    multi_accept on;
}


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"';
    log_format  log404 '$status [$time_local] $remote_addr $host$request_uri $sent_http_location';

    access_log  /home/sasuke/app/log/access.log  main;
    access_log  /home/sasuke/app/log/access.404.log  log404;
    
    sendfile       on;
    tcp_nopush     on;

    proxy_connect_timeout 90;
    proxy_read_timeout 180;
    proxy_send_timeout 180;
    
    keepalive_timeout  120;
    tcp_nodelay on;
    proxy_intercept_errors on;

    server {
        listen       80;
        server_name  10.20.24.131;
        charset      utf-8;

        access_log   /home/sasuke/app/log/host.access.log  main;
        add_header   'Access-Control-Allow-Origin' '*';

        location / {
            index index.html index.htm;
        }

        location ^~ /app/ {
            proxy_pass        http://10.20.24.131:9800;
            proxy_redirect    off;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

    #location ~ .*.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|json)$ {
    #    root /home/sasuke/app/web/www;
    #    expires -1;
    #}

        location ~ .*$ {
            root /home/sasuke/app/web/www;
            expires -1;
        }
    }
    
}

服务器上nginx.conf 的配置文件如下

Last login: Tue Jun 12 09:58:04 on ttys001
C02VQ00YHTD7:~ gaoyizhen736$ ssh root@43.240.128.93
root@43.240.128.93's password: 
harset      utf-8;

        access_log   /home/sasuke/app/log/host.access.log  main;
        add_header   'Access-Control-Allow-Origin' '*';

        location / {
            index index.html index.htm;
        }

        location ^~ /app/ {
            proxy_pass        http://10.20.24.131:9800;
            proxy_redirect    off;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

	#location ~ .*.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|json)$ {
	#    root /home/sasuke/app/web/www;
	#    expires -1;
	#}

        location ~ .*$ {
            root /home/sasuke/app/web/www;
            expires -1;
        }
    }
	
}


Permission denied, please try again.
root@43.240.128.93's password: 
Last failed login: Tue Jun 12 10:09:26 CST 2018 from 101.89.64.6 on ssh:notty
There were 2 failed login attempts since the last successful login.
Last login: Tue Jun 12 09:58:58 2018 from 101.89.64.6
WARNING: If you are not authorized to access this private computer system, disconnect now. All activities on this system will be monitored and recorded without prior notification or permission!
**************************************************************************
*                                                                        *
*Attention: Auditing process will report your every action!              *
*Warning: Don't delete any files in directory /root/slogs!!              *
*                                                                        *
*                          -PING AN INSURANCE (GRP) COMPANY OF CHINA,LTD.*
**************************************************************************
Script started, file is /root/slogs/2018-06-12_10:09:37pts-0root.log
[root@ECA-LJ3600096 ~]# cd /
[root@ECA-LJ3600096 /]# cd etc/nginx
[root@ECA-LJ3600096 nginx]# ls
conf.d                  koi-utf             scgi_params
default.d               koi-win             scgi_params.default
fastcgi.conf            mime.types          uwsgi_params
fastcgi.conf.default    mime.types.default  uwsgi_params.default
fastcgi_params          nginx.conf          win-utf
fastcgi_params.default  nginx.conf.default
[root@ECA-LJ3600096 nginx]# vim nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user root;
#user nginx;//权限不够改成user root  重启的时候需要带上sudo
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
                                                               

免责声明:文章转载自《nginx --反向代理配置文件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇XSS防御策略Linux下测试SSD固态硬盘写入速度下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

(转)MySQL 8 新特性之Clone Plugin

原文:https://www.cnblogs.com/ivictor/p/13818440.html#top Clone Plugin是MySQL 8.0.17引入的一个重大特性,为什么要实现这个特性呢?个人感觉,主要还是为Group Replication服务。在Group Replication中,添加一个新的节点,差异数据的补齐是通过分布式恢复(Di...

Nginx反向代理WebSocket链接失败问题

问题记录:本地socket测试无误后部署发现 WebSocket connection to "xxx/xxx" failed  解决方案: 在nginx.conf的http模块添加如下内容 map $http_upgrade $connection_upgrade { default upgrade; '' close; } 其...

uni-app request POST 请求方式不加 header头会默认为 OPTIONS

背景:鄙人在测试 uniapp 的使用时,发现以 POST 方式进行网络请求时,如果不添加 header 头 是无法进行正常的网络请求的,此时默认的请求方式被认定为 OPTIONSuni.request 发起请求 源码截图 网络请求示意图   此时,如果添加如下的 header头 header: { 'content-type': 'app...

Nginx超时timeout配置总结

具体参数解释 Nginx 处理的每个请求均有相应的超时设置。如果做好这些超时时间的限定,判定超时后资源被释放,用来处理其他的请求,以此提升 Nginx 的性能。 keepalive_timeout HTTP 是一种无状态协议,客户端向服务器发送一个 TCP 请求,服务端响应完毕后断开连接。如果客户端向服务器发送多个请求,每个请求都要建立各自独立的连接以传输...

Mysql+Keepalived双主热备高可用操作记录

我们通常说的双机热备是指两台机器都在运行,但并不是两台机器都同时在提供服务。当提供服务的一台出现故障的时候,另外一台会马上自动接管并且提供服务,而且切换的时间非常短。MySQL双主复制,即互为Master-Slave(只有一个Master提供写操作),可以实现数据库服务器的热备,但是一个Master宕机后不能实现动态切换。使用Keepalived,可以通过...

用C#写了个日志类

日志的作用我想不必我多说了,在做BS架构的程序的时候,我们通常会把日志写在数据库的某张表中,这样带来的好处是便于查询,使用SQL语句十分方便而灵活,但缺点也是显而易见的,那就是造成数据库负担过重,随着日志不断增加,表的尺寸也会变得越来越庞大,性能也会渐渐下降,所以我打算把日志保存到文本文件中去,纯文本文件的写入可是要比数据库快很多的。 然而目前已经存在的日...