Quantcast
Channel: Nginx Forum - How to...
Viewing all 2931 articles
Browse latest View live

nginx - cache VOD (no replies)

$
0
0
Hi,

I have a problem with configuring cache in nginx.
I need to cache the VOD stream from origin on disks for a long time. Once the material has been cached on the disk everything works fine, the player gets chunks from the disks. The problem arises when the material on the origin side has been swapped. Nginx does not know that the material has been modified and gives the player chunks from the disc instead of the origin.

How do I need to configure nginx to check when the VOD material was last modified and if it has current on the disk, it was given from disk and when on origin is newer it was given from origin and then cached?

my configuration:


#############################################################################################

proxy_cache_path /testy levels=1:2 keys_zone=my_cache:100m max_size=2100g inactive=4800h use_temp_path=off;

server {
listen 80;
server_name default;

location ~ / {
proxy_cache_key "$request_uri$http_last_modified";
proxy_pass http://127.0.0.1:6081;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache my_cache;
proxy_cache_valid 200 206 4800h;
proxy_cache_revalidate on;
proxy_cache_background_update on;
proxy_cache_min_uses 1;
proxy_cache_use_stale updating error timeout http_500 http_502 http_503 http_504;
proxy_cache_lock on;
}}

#############################################################################################

nginx output problem (no replies)

$
0
0
I have a program (like prg) which can receive some requests and return something(like a reply message).I wonder if a client send some requests through nginx to this program,how can I give the client the reply produced by the program?
Firstly I tried fastcgi and C.I wrote a fastcgi C program to fork a process to execute the program(prg).But unfortunately it didn't work ,although the cgidemo can run on my machine,and I can type some requests and get some reply.But with nginx there was no output.And it just said some error happened.
And someoen told me that I can develope a nginx module to execute the program prg.And get its file descriptor.Then use dup2 to rewrite the output to the file descriptor and return to the client.But I just feel a bit confused about getting the file descriptor,how can I do it ?Or is there any other way to do this job?

One NGINX load balancer for two functionnalities (no replies)

$
0
0
Hello,
I'm looking for some help on NGINX as a load balancer.

I currently have the attached configuration file which represents production instances. NGINX redirects everything that happens on ports 80 and 443 to my production instances to production.

I would like to add two test instances such as:
www.monserveur.fr:8080 (http) --> www.monserveur.fr:8181 (https)
www.monserveur.fr:8181 (https) --> www.monserveur.fr:31081 or www.monserveur.fr:32081

how can I set this up in NGINX? do I need to create other server sections {} and another upstream session {}

I need your help to move forward.
thanks
thierry

Custom config for different domains (in Plesk) (no replies)

$
0
0
My server is a VPS with Plesk installed.
This manages multiple domains with sub-domains, each with its own applications.

Some of these applications need special configurations, starting with the "location" directive which is centrally managed in Plesk.
I could generate a custom configuration, but it would still be valid on all domains.

So, my idea is to generate a "master" file that for some domains (or subdomains) make an include of custom configurations, while for all others there is the standard configuration.

But I know little about the configuration of Nginx and so I would be grateful if you could give me some directions and some advice.

Thanks in advance.

How to use Nemesida WAF Free (no replies)

$
0
0
Nemesida WAF Free provides the base web application security against OWASP class attacks based on the signature method. Nemesida WAF Free has its own signature base, detects attacks on web applications with a minimum number of false positives, is updated from the Linux repository, installed and configured in a few minutes.

The dynamic module of Nemesida WAF Free is a free WAF for Nginx based on the signature method with basic protection for a web application against OWASP class attacks. Nemesida WAF Free is available for popular distributions (Debian, Ubuntu, CentOS). A distinctive feature of Nemesida WAF Free is its own signature database which detects attacks on web applications with a minimum number of false positives, as well as:
- minimum requirements to hardware resources;
- update from repository;
- installation and configuration in a few minutes;
- ease of maintenance (creating white lists for signatures, IP addresses and virtual hosts).

The dynamic module Nemesida WAF is available for:
- Nginx stable from 1.12;
- Nginx mainline from 1.17;
- Nginx Plus from 18 (R18).
- In the case of compiling Nginx from the source code, you should add the --with-compat parameter during the run configure to activate support of the dynamic module.


Installation (Debian 9 for example):

#######################################################

# apt install apt-transport-https
# echo "deb http://nginx.org/packages/debian/ stretch nginx" > /etc/apt/sources.list.d/nginx.list
# echo "deb https://repository.pentestit.ru/nw/debian stretch non-free" > /etc/apt/sources.list.d/NemesidaWAF.list</pre>

# wget -O- https://nginx.org/packages/keys/nginx_signing.key | apt-key add -
# wget -O- https://repository.pentestit.ru/nw/gpg.key | apt-key add -

# apt update && apt upgrade
# apt install nginx

# apt install librabbitmq4 libcurl4-openssl-dev libc6-dev python3-pip python3-dev python3-setuptools dmidecode gcc
# pip3 install --no-cache-dir pandas requests psutil sklearn schedule simple-crypt fuzzywuzzy levmatch python-Levenshtein
# apt install nwaf-dyn-1.16

#######################################################

where 1.16 is the version of the installed Nginx. For example, package of the dynamic module nwaf-dyn-1.12 is intended for work with Nginx version 1.12 and nwaf-dyn-1.15 is intended for work with Nginx Plus Release 18.


Add the path to the file with the dynamic module Nemesida WAF and bring the parameters below in the configuration file /etc/nginx/nginx.conf to the form:

#######################################################

load_module /etc/nginx/modules/ngx_http_waf_module.so;
thread_pool nw threads=32 max_queue=65536;
...
worker_processes auto;
...
http {
...
##
# Nemesida WAF
##

## Request body too large fix
client_body_buffer_size 25M;

include /etc/nginx/nwaf/conf/global/*.conf;
include /etc/nginx/nwaf/conf/vhosts/*.conf;
...
}

#######################################################

To update signatures, provide access to https://nemesida-security.com. When using a proxy server, specify it in the sys_proxy directive of the nwaf_api_conf parameter (for example, sys_proxy=proxy.example.com:3128).

Restart the server and test :

#######################################################

# systemctl restart nginx.service nwaf_update.service
# systemctl status nginx.service nwaf_update.service

#######################################################

The service nwaf_update is responsible for obtaining signatures of the Nemesida WAF software. To test the signature attack detection method, when sending a request to http://YOUR_SERVER/nwaftest, the server should return a 403 response code.

- More information about installation on Debian/Ubuntu/CentOS: https://waf.nemesida-security.com/about/1701
- Virtual Appliance: https://repository.pentestit.ru/vm/NemesidaWAF-TrialVM.zip
- Nemesida WAF Rules: http://rlinfo.nemesida-security.com

Multiple site in same server configuration issue (no replies)

$
0
0
I am trying to host 2 websites in a single server. Attached files are the configuration for the sites. When I enabled both, site1 works fine but site2 is going to site1. Could anyone point to the problem? Much appreciated

Read the Request Body and return 200 OK (no replies)

$
0
0
Hi ,

We are building up the speed test like server on nginx. On the Upload side we need some help on configuring the nginx.

The client send some random bytes over POST. The nginx backend just read the bytes and return 200Ok.

Is there any simple conf to do that.

We used Lua support to write the POST data to a file. The disk IO is overhead here .

We need not process the POST data instead just read the bytes and do nothing and return 200.

NGINX -500 error on form submission (no replies)

$
0
0
We are getting some errors from an IP address (500 Internal Error on POST event and upstream response buffer) and we don't know if this a genuine client trying to submit our contact form or a spam bot. The logs show the following information:

[code]
25/07/2019
19:23:28.000 +0100
77.243.191.40 - - [25/Jul/2019:19:23:28 +0100] "POST /contact/ HTTP/1.0" 500 91888 "https://www. example.com/contact/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36 OPR/53.0.2907.99"
Host: example Name: /var/log/nginx/access.log Category: nginx
2 25/07/2019
19:23:27.000 +0100
77.243.191.40 - - [25/Jul/2019:19:23:27 +0100] "GET /contact/ HTTP/1.0" 200 91888 "https://www.example.com/contact/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36 OPR/53.0.2907.99"
Host: example Name: /var/log/nginx/access.log Category: nginx
3 24/07/2019
18:00:49.000 +0100
2019/07/24 17:00:49 [warn] 20454#20454: *68024 an upstream response is buffered to a temporary file /var/lib/nginx/fastcgi/2/39/0000000392 while reading upstream, client: 77.243.191.40, server: , request: "GET /contact/ HTTP/1.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.example.com", referrer: "https://www.example.com/contact/"
Host: example Name: /var/log/nginx/error.log Category: nginx
4 24/07/2019
17:00:50.000 +0100
77.243.191.40 - - [24/Jul/2019:17:00:50 +0100] "POST /contact/ HTTP/1.0" 500 105548 "https://www.example.com/contact/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"
Host: example Name: /var/log/nginx/access.log Category: nginx
5 24/07/2019
17:00:49.000 +0100
77.243.191.40 - - [24/Jul/2019:17:00:49 +0100] "GET /contact/ HTTP/1.0" 200 105521 "https://www.example.com/contact/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"
Host: example Name: /var/log/nginx/access.log Category: nginx
[/code]

Our main configuration NGINX file is as follows:

user www-data;
worker_processes 2;
pid /run/nginx.pid;
worker_rlimit_nofile 100000;

events {
worker_connections 2048;
multi_accept on;
}

http {

##
# Basic Settings
##

client_header_buffer_size 2k;
large_client_header_buffers 2 1k;

client_body_buffer_size 10M;
client_max_body_size 10M;

client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

map $http_user_agent $bot_in_log {

~Pingdom 0;
~Preload 0;
~Googlebot 0;
~Baiduspider 0;
default 1;

}

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";
gzip_proxied any;
gzip_buffers 16 8k;
gzip_comp_level 4;
gzip_http_version 1.0;
gzip_min_length 1280;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss a$
gzip_vary on;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

}

I have read on another thread this might help with buffer overruns but I am not sure if I should add this to our config. We are running a wordpress site.

proxy_buffers 16 16k;
proxy_buffer_size 16k;

Nginx Service Failed Error (no replies)

$
0
0
Hi all, I am new to this forum. ApoIogies, if I have posted this in the wrong section. I am relatively new to nginx and have installed and configured it as a reverse proxy. All the virtual hosts I have set up thus far are working fine. The problem has arisen with the setting up of my first virtual host listening on port 443 and proxy passing to a https upstream server. Once configuring the file, when I then go to reload the nginx service I get the error "Job for nginx.service failed because the control process exited with error code...". I did some investigating and thought maybe I needed to recompile the whole installation with the ssl module (--with_http_ssl_module) but I have nginx and nginx-common installed (I installed with the apt package manager) and according to my research, the ssl module should already come with nginx-common (unless there is something I am missing? Do I need to enable it somehow?). Please find the code for my reverse proxy configuration below. Any help is greatly appreciated!

server {
listen 443 default SSL;
server_name example.local www.example.local;

ssl_prefer_server_ciphers on;
ssl_protocols TLVv1 SSLv3;
ssl_ciphers RC4:HIGH:!aNULL:!MD5:@STRENGTH;
ssl_session_cache shared:WEB:10m;

ssl_certificate /etc/nginx/ssl/ssl.crt;
ssl_certificate_key /etc/nginx/ssl/ssl.key;

index index.htm index.html index.php

location / {
proxy_set_header X-Forwarded-Proto https;
proxy_pass https://server.local;
}
}

How can I put content on an external disk? autoindex (no replies)

$
0
0
Hello, Im Eloy, i have a server on nginx, this is my virtual server

server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;

index index.html index.php;

server_name _;

location /data/ {
autoindex on;

}

# This option is important for using PHP.
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
}
}


My configuration of server

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

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

##
# Gzip Settings
##

gzip on;

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:1ccc;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:1ccc;
# protocol imap;
# proxy on;
# }
#}

Me he dado cuenta que yo solo tengo 768 worker conecctions y que el tiene como 1024, luego ya no

Luego tiene esto

server {
listen 80;
server_name localhost;
root html;

access_log logs/host.access.log main;

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

}

}




I tried put this chown -R www-data:www-data /media/odroid/Maxtor/data/

chown -R www-data:www-data /usr/local/nginx/html/

service nginx destroy && service nginx start


But it has not taken effect, and I still have no permissions, even putting root.


I just want to leave the data folder on an external hard drive.

Since it is currently inside the html folder.

Thank you my web page is very old www.eloy.mooo.com

Replace TMG and custom HTTP header component (no replies)

$
0
0
We are working to replace TMG and a 'custom component' that (when an HTTP request is made) inserts 'application and role' information obtained from the users Active Directory group membership.  It inserts this data (i.e. Role:AA, AB) into the header of the request which is then 'inspected' down the pipeline to determine a users access.

My question is does NGINX allow for this same functionality?  If so what product does that?

Thank you!

Rewrite to subdirectory (no replies)

$
0
0
Hello,
I am new to nginx.
I am trying to do redirect but I am not sure how.
I want to redirect all trafic to from mysite to a subdirectory under www. For example I want:
mydomain.com/*, www.mydomain.com/*
to go at:
www.mydomain/el/*

how can I make ti happen?

PHP-FPM NGiNC Memory (no replies)

$
0
0
Hello.
I have site on nginx1.10.3 wich reads from db a lot of records, makes an ordering with php7.3-fpm and then served to the public.
Records are quite few and I would like to give it more memory so as to perform better.
I dont know where this extre memory should be given. To nginx or to php7.3-fpm?

any help is appreciated.

Display a different page base on the parent (i) frame domain (no replies)

$
0
0
Hello,
I am trying to load 3 different pages when :
1 - the page is directly loaded on the website utl
2 - the page is included in an iframe on a specific domain
3 - the page is included in an iframe on all other domain

What would be the best way to do that ?

Thanks a lot

Nginx as a reverse proxy with client certificate (no replies)

$
0
0
Hi,

I have the following scenario

_____________________
| app (backend) --> nginx | --> server (3rd party)
-----------------------------------

We have a backend that want to do third-party requests to a server that requires client certificate, but we want to avoid adding the client certificate on the app, and instead do this with Nginx. Is this possible? If so, how can this be set up?

Bad NGINX config for Joomla (1 reply)

$
0
0
Hello all,

I am needing the assistance from someone smarter then me on NGINX configurations. This is my first time doing a Joomla site with NGINX (I have done a few Wordpress sites without issue). I got NGINX installed and it works fine, joomla is installed and I can access the site but I am having issues with how the site is loading

I originally used the following code:
-------------------------------------------------------------
server {
listen 80;
listen [::]:80;
root /var/www/html/joomla;
index index.php index.html index.htm;
server_name example.com www.example.com;

client_max_body_size 100M;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
-------------------------------------------------------------
This code worked great for the front end. However the administrator page of joomla would load without any CSS formatting. The attached image is not of my site but it is the same issue.

So i searched around on the internet and I found this NGINX configuration:
-------------------------------------------------------------
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html/joomla;
index index.php index.html index.htm;

location / {
if ($request_uri ~ ^/(.*)\.html$) {
return 302 /$1;
}
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}
-------------------------------------------------------------
This code allowed the backend to load properly however the front end would load the main page however no link worked (resulted in 404 error) until I disabled SEF URL's and then it partially worked as some parts of the theme we are trying to use requires SEF URL's otherwise they don't load properly.

I tried to add the recommended code Joomla has on their document page for enabling SEF URL's in the second configuration but it I always get 1 of 3 results.

1. No Change
2. NGINX fails to start
3. When selecting SEF enabled and applying the save results in SEF reverting back to Disabled.

For a bit more info I am running this on Ubuntu with PHP 7.2 and all changes were being made to the site file in /etc/nginx/sites-available /website

Thanks for any help you can provide

How do I run existing nginx repo on windows or ubuntu (no replies)

$
0
0
I am a freelance front-end developer, just enough PHP, Apache and Unix to get by. **ZERO NGINX**. To work on this client's site I need to work with this repo (file tree below).

I've researched enough to:

- Install nginx and know that I can point my nginx to the configuration file in this repo.
But I get user errors `(nginx: [emerg] getpwnam("system") failed)` then `nginx: [emerg] unknown directive "dav_ext_methods"` and I'm just going down a rabbit hole.

- I've also tried nginx on Laragon and tried to modify the Laragon nginx templates to no avail.

- I've installed nginx on WSL but there is far to much configuration to learn to make this work on time.

- I have also installed CLion to try and use its environment configuration (CMakeLists.txt) but again, not familiar at all with that IDE. Made me install cygwin, CMake and a bunch of other stuff... another time sucking rabbit hole.


I need help!!

I am hoping that someone can look a the contents of this repo and give me some steps to follow.

webapp
| .gitignore
| CMakeLists.txt
| php-fpm.conf
|
+---.git
|
+---html
|
+---init
| nginx.service
|
+---nginx_cfg
| fastcgi_params
| mime.types
| naxsi.rules
| naxsi_core.rules
| nginx.conf
| nginx_user_cert.conf
| scgi_params
|
+---php-fpm.d
| www.conf
|
\---themes

browser requet to proxy is using localhost (no replies)

$
0
0
Hey,

This is an obvious question, must have been asked, but I could not find existing ones.

I have a jetty web server using localhost:8080. I am using nginx as proxy with www.somedomain.com.
I have configured it working for first page, access www.somedomain.com redrects to localhost:8080.
But the links in the web pages downloaded to browser are still using loalhost:8080/**, it should be using www.somedomain.com.
What should I do to ensure all page links are using proxy url, www.somedomain.com, not localhost:8080.

Thanks in advance for any input/pointers.

G

fresh nginx install won't start: lacks permission to bind to port 80 (no replies)

$
0
0
This is a new one on me after maybe a dozen or so NGINX installs on Ubuntu 18.04. This happened on a Windows 10 machine using the Windows Subsystem for Linux, running Ubuntu 18.04 freshly installed. Nothing else has been installed.

Here's what I get:

doctor@Lenovo-Ideapad2:~$ sudo service nginx start
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
doctor@Lenovo-Ideapad2:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed

In Windows right after this happened I checked Port 80:

C:\WINDOWS\system32>netstat -aon | findstr :80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 192.168.1.119:52240 72.21.91.29:80 CLOSE_WAIT 12636
TCP [::]:80 [::]:0 LISTENING 4
TCP [2604:6000:1513:49d4:75ef:2fb6:7dba:daaf]:52472 [2001:4998:60:800::1105]:443 ESTABLISHED 13304


Why is this happening?

Thanks.

How do I Reverse proxy to different sites and servers (no replies)

$
0
0
Hello,
I did my first steps with nginx and set up a reverse proxy on a raspberry pi.

Until now it works the following way:

MyDyndnsdomain.com -> points to an internal IP Webcam 192.168.1.25

This works as expected using https with certbot and lets encrypt. But as a next step I want to expand the setup to multiple international servers, for example:

MyDyndnsdomain.com/cam1 -> points to an IP Webcam #1 192.168.1.25

MyDyndnsdomain.com/cam2 -> points to an IP Webcam #2 192.168.1.26

MyDyndnsdomain.com/Home -> points to an Webserver 192.168.1.27/html/Homepage

MyDyndnsdomain.com/webdav -> points to a WebDAV storage 192.168.1.28

Do I have to configure these as different virtual servers or are „locations“ what I need to look into?

Best regards

S
Viewing all 2931 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>