hosting image

Five M FXServer Reverse Proxy NGINX

Preferred Requirements

-Nginx 1.19

-Centos 7

 

Install the EPEL repository:

$ sudo yum install epel-release

 

Update the repository:

$ sudo yum update

 

Install NGINX Open Source:

$ sudo yum install nginx

 

Verify the installation:

$ sudo nginx -v
nginx version: nginx/1.19

 

in /etc/nginx/nginx.conf add the following line after http block:

include /etc/nginx/proxy.conf;

 

create this file in the path /etc/nginx/proxy.conf with following:

stream {
upstream backend{
server ip:port;
}
server {
listen 30120;
proxy_timeout 300s;
proxy_pass backend;
}
server {
listen 30120 udp reuseport;
proxy_timeout 300s;
proxy_pass backend;
}
}

 

edit file default.conf

upstream backend {
server ip:port;
}
proxy_cache_path /srv/files levels=1:2 keys_zone=assets:200M max_size=20g inactive=7d use_temp_path=off ;
log_format asset '$remote_addr - [$time_local] "$request" $status $body_bytes_sent $upstream_cache_status';

server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location /files/ {
aio threads;
tcp_nodelay on;
directio 50k;
access_log /var/log/nginx-access.log asset;
error_log /var/log/nginx-error.log;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache_lock on;
proxy_connect_timeout 300s;
proxy_pass http://ip:port$request_uri;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache assets;
proxy_cache_valid 1y;
proxy_cache_revalidate on;
proxy_cache_min_uses 1;
proxy_cache_key $request_uri$is_args$args;
}
}

 

 

set this details in your server.cfg in your server

sv_forceIndirectListing true
sv_listingHostOverride yourhost.yourdomain.com
sv_listingIpOverride "proxy.ip"
sv_proxyIPPranges "proxyip/32"

# below is optional if you are not using the caching proxy
adhesive_cdnKey "randomKeyHere"
fileserver_add ".*" "https://proxyip/files"

 

your good to go !

Leave a Reply

Your email address will not be published. Required fields are marked *