I'm building a website that I'm running through a docker container. I am receiving this error
webserver_1 | 2019/10/01 17:50:24 [emerg] 1#1: unexpected "}" in /etc/nginx/nginx.conf:36
webserver_1 | nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:36
All of the curly brackets are counted for and removing this one (it's the third to last brace) would leave me with an uneven number.
This is my nginx.conf. Does anyone know what's going on?
user nginx;
worker_processes 1;
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 main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
location /api {
auth_basic 'closed site';
auth_basic_user_file /etc/nginx/conf.d/.htpasswd
}
}
}
Related
I have been looking for a way to configure my Nginx to listen to POST requests of webhooks from Github.
I configured a new Webhook in Github as follows:
Payload URL: https://myUrl/payload Secret: thisisthesecret
My goal is to tell Nginx: once you receive POST request (Github webhook in my case), if the header you got matches "thisisthesecret" then return "OK" and put the payload under https://myUrl/payload
Except for this example I couldn't find any implementation of it online so I am reaching out to your assistance.
This is my current nginx.config file:
user nginx;
worker_processes 1;
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 main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
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!
Nginx directory is disexist under /usr/local.
My server's os is centos 7.2 64 bit.
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 main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf; }
I found it by mysself.
/usr/share/nginx/html
Ubuntu 15.10
Using this run command with the official nginx image:
sudo docker run -dit --name="myApp" -p 8181:80 -v /home/username/Documents/My\ Folder/Repos/my-app:/usr/share/nginx/html:ro -v /home/username/Documents/My\ Folder/Repos/my-app/nginx.conf:/etc/nginx/nginx.conf:ro nginx
It runs fine without the 2nd VOLUME declaration (without the custom nginx.conf), but I recently added it because I need to configure some things (AngularJS html5 routing mode).
My nginx.conf (All I did was add the location settings, everything else was copied over from the original):
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
location / {
root /home/username/Documents/My Folder/Repos/my-app;
try_files $uri index.html;
}
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 main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Your location block should be within a server block:
server {
location / {
root /home/username/Documents/My Folder/Repos/my-app;
try_files $uri index.html;
}
}
A tutorial for some more information: https://www.digitalocean.com/community/tutorials/understanding-the-nginx-configuration-file-structure-and-configuration-contexts#the-location-context