阿里云大数据服务器安装代理nginx端口转发

网友投稿 306 2022-11-23

阿里云大数据服务器安装代理nginx端口转发

1.下载yum源 yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo 2.安装openresty服务 yum -y install openresty openresty-resty 3.添加nginx服务

vim /usr/lib/systemd/system/openresty.serviceExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -c /etc/nginx/nginx.confExecStart=/usr/local/openresty/nginx/sbin/nginx -c /etc/nginx/nginx.conf

4.添加服务systemctl daemon-reloadcp /usr/local/openresty/nginx/conf /etc/nginx/ -Rmkdir /etc/nginx/vhosts

5.添加开机服务

systemctl enable openresty

6.配置nginx代理

vim /etc/nginx/nginx.conf

user   webgrp;

worker_processes  2;#worker_cpu_affinity  0001 0010 0100 1000;worker_rlimit_nofile    102400;pid /usr/local/openresty/nginx/logs/nginx.pid;#pid  /var/run/nginx.pid;#google_perftools_profiles /data/ /var/log/nginx_error.log  info;

events {    worker_connections 102400;    use epoll;}

{    include  /etc/nginx/mime.types;    server_names_hash_bucket_size 128;    client_header_buffer_size 32k;    large_client_header_buffers 4 32k;    client_max_body_size 1024m;

default_type  application/octet-stream;

proxy_hide_header X-Powered-By;     proxy_hide_header Server;

sendfile        on;

keepalive_timeout  65;    tcp_nodelay on;

fastcgi_connect_timeout 1800;    fastcgi_send_timeout 1800;    fastcgi_read_timeout 1800;    fastcgi_buffer_size 128k;    fastcgi_buffers 4 256k;    fastcgi_busy_buffers_size 256k;    fastcgi_temp_file_write_size 256k;

add_header X-Cache-CFC "$upstream_cache_status - $upstream_response_time 221"; #   fastcgi_temp_path /data/  fastcgi_cache_path /data/levels=1:2 keys_zone=ngx_fcgi_cache:1024m inactive=15m max_size=16g;    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

#  proxy_temp_path /data/#  proxy_cache_path /data/levels=1:2 keys_zone=ngx_proxy_cache:1024m inactive=6h max_size=10g;

log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '        '$status $body_bytes_sent "$'        '"$ $$request_body '         '"$upstream_cache_status" $upstream_status'        ' upstream_response_time $upstream_response_time request_time $request_time';

log_format  access-s  '$remote_addr - $remote_user [$time_local] "$request" '        '$status $body_bytes_sent "$'        '"$ $'         '"$upstream_cache_status" $upstream_status'        ' upstream_response_time $upstream_response_time request_time $request_time';

log_format  access-url  'curl  -s "-d  "$request_body" ';

open_log_file_cache  max=1000 inactive=60s;

limit_req_zone  $binary_remote_addr  zone=qps1:1m   rate=1r/s;    limit_req_zone  $binary_remote_addr  zone=qps2:1m   rate=2r/s;    limit_req_zone  $binary_remote_addr  zone=qps3:1m   rate=3r/s;

proxy_hide_header X-Powered-By;        proxy_hide_header Server;        access_log /var/log/access.log access;        server_tokens off;

gzip  on;    gzip_min_length  1k;    gzip_buffers     4 16k;    gzip_1.0;    gzip_comp_level 2;    gzip_types       text/plain application/x-javascript text/css application/xml;    gzip_vary on;

map $ $clientRealIp {        ""      $remote_addr;        ~^(?P[0-9\.]+),?.*$  $firstAddr;     }

#    upstream common{#        server 127.0.0.1:9000;#        server 127.0.0.1:9001;#        server 127.0.0.1:9002; #   }

fastcgi_next_upstream error timeout invalid_header  server   # {   #     listen 80 default;   #     server_name _;    #     return 444;   # }    include vhosts/*.conf;

}

7. 添加大数据服务器需要代理的服务

vim /etc/nginx/vmhost/all.conf

#yarn

server {    listen 120.79.20.59:8088;    server_name 120.79.20.59 dbos-bigdata-test002;

index index.html index.htm index.php;

#include /usr/local/nginx/conf/allow_ip.conf;        # deny all;    location / {        proxy_pass   }

access_log  /data/logs/access/test.com.access.log  access;    error_log   /data/logs/error/test.com.error.log warn;}

# namenode

server {        listen 120.79.20.59:9870 ;        server_name 120.79.20.59 dbos-bigdata-test002;

index index.html index.htm index.php;

#   include /usr/local/nginx/conf/allow_ip.conf;     #   deny all;        location / {            proxy_pass       }}

# yarn history

server {        listen 120.79.20.59:19888 ;        server_name 120.79.20.59 dbos-bigdata-test002;

index index.html index.htm index.php;

#   include /usr/local/nginx/conf/allow_ip.conf;     #   deny all;        location / {            proxy_pass       }}

# oozie

server {    listen 120.79.20.59:11000;    server_name 120.79.20.59 dbos-bigdata-test002;    index index.html index.htm index.php;    location / {        proxy_pass   }    access_log  /data/logs/access/test.com.access.log  access;    error_log   /data/logs/error/test.com.error.log warn;}

8.重新openresty加入配置

systemctl reload  openresty

9.重启openresty服务

systemctl restart openresty

10.访问各个服务测试

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:泰克公司推出业内首个物理层DiiVA一致性测试解决方案
下一篇:C语言每日练习之求两个矩阵的乘积详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~