Here is my config:
nginx.conf
user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
use epoll;
}
http {
client_max_body_size 15m;
server_names_hash_bucket_size 64;
postpone_output 1460;
sendfile_max_chunk 128k;
sendfile on;
fastcgi_cache_path /tmp/fcgi-cache/ levels=1:2 keys_zone=one:10m;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
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;
error_log /var/log/nginx/error.log;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
ssi on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
here is my domain.com config in sites-available:
server {
root /var/www/domain.com/;
access_log /var/log/nginx/default-access.log;
error_log /var/log/nginx/default-error.log;
include /etc/nginx/templates/default;
include /etc/nginx/templates/php;
include /etc/nginx/templates/phpmyadmin;
}
When i enter a url domain.com it shows default nginx page. When i comment include /etc/nginx/conf.d/*.conf; i can't even load nginx page, it lools like server is not even working. I've written my site in sites-available and made a ln -s to sites-enabled.
What is wrong?
You have to put server_name domain.com; in server block :)
Related
I am trying to configure NGINX to serve my nest app(which is running on docker).
My app is listening on port 3000
The server is amazon linux 2(ec2-user)
The conf file looks like this:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
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;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
#include /etc/nginx/conf.d/nginx.conf;
server {
listen 80;
listen [::]:80;
server_name <ip.adress>;
#web
location / {
add_header X-yahav $uri; # this gets mounted
}
#api
location = /api { # this one is never approached
add_header X-yahav "Api-pass";
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header Host $http_host;
#proxy_pass http://127.0.0.1:3000/;
}
}
}
I want to redirect /api to my nest app but it just wont have it i'm getting a simple 404 without the header i'm attaching(as you can see in the conf file)
Another thing is when I go to the root (location /) I do get my header mounted as expected
Any have any idea what is wrong?
Don't forget to add "/api" to your requests, like http://your-server:80/api/
Sorry, but no matter what I try, there are always error messages?
I have no idea, what is wrong with my file?
---nginx.conf---
#user nginx;
worker_processes 1;
#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
#pid /var/run/nginx.pid;
include /etc/nginx/modules.conf.d/*.conf;
events {
worker_connections 1024;
}
location / {
client_max_body_size 2024M;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 2024M;
#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 0;
keepalive_timeout 65;
#tcp_nodelay on;
#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
server_tokens off;
include /etc/nginx/conf.d/*.conf;
server {
client_max_body_size 2024M;
}
}
# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;
Who can help me so I understand where my mistake is?
I'm trying "client_max_body_size 2024M;" to integrate (html / server / location).
Thank you all!
I tried installing nginx with virtual hosting enabled with a single site currently hosted.
my nginx.conf
user nginxsite;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
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;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
#server_names_hash_bucket_size 64;
}
I assume that the user nginxsite; is the useradd created for the root directory ownership. default of that is just nginx.
my virtual.conf inside /etc/nginx/conf.d/
server {
listen 80;
#listen *:80;
server_name www.nginxsite.domain.com *.nginxsite.domain.com;
#access_log /var/log/nginx/access.log
location / {
root /var/www/nginxsite.com/public_html/;
index index.html index.htm; }
}
The server name and ip has already been added in my hostfile
XX.XX.XX.XX www.nginxsite.domain.com
I'm pretty sure the issue lies in my conf files but I can't seem to point out where.
Checked the logs but there's nothing.
Please help.
Thanks so much!
Below is my nginx.conf file, I have two upstreams, http_upstream and tcp_upstream, I make duplicated HTTP traffic and send it to load-balancer2.example.com:80 by using post_action, now I am wondering if I could make duplicated TCP/UDP traffic by using something similar to post_action?
daemon on;
user root;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
stream {
upstream tcp_upstream {
server server1.example.com:2000;
server server2.example.com:2000;
server server3.example.com:2000;
}
server {
listen 2000;
proxy_pass tcp_upstream;
}
}
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;
client_header_buffer_size 512k;
large_client_header_buffers 4 512k;
client_max_body_size 1000M;
client_body_buffer_size 1000M;
upstream http_upstream {
server server1.example.com:8088;
server server2.example.com:8088;
server server3.example.com:8088;
}
server {
listen 80;
location / {
proxy_pass http://http_upstream/;
post_action #post_action;
}
location #post_action {
proxy_pass http://load-balancer2.example.com:80;
}
}
include /etc/nginx/conf.d/*.conf;
}
I want to reverse proxy 172.17.0.6:8080/swagger-u.html or 172.17.0.8:8080/swagger-u.html by 172.17.0.4:8080/swagger-u.html, i need configuration for Nginx, some help please!
this is my nginx.conf:
[root#5e1ae14b79e8 /]# vi /etc/nginx/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 nginx;
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 {
upstream backends {
server 172.17.0.7:8012 weight=3;
server 172.17.0.6:8012;
}
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;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 172.17.0.4;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /wagger-u.html/ {
proxy_pass http://backends;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
error_page 404 /404.html;
location = /40x.html {
But,I visit 172.17.0.4:8080/swagger-u.html,it is 404!