I am learning how to deploy AWS for the first time. I am following this guide here: https://www.youtube.com/watch?v=HtWgb_vbyvY.
I am using windows machine while the person in the video uses mac.
I am getting the following error when running ngnix commands on the windows terminal: "nginx: [emerg] CreateFile() "C:/nginx-1.23.0/nginx-1.23.0/mime.types" failed (3: The system cannot find the path specified) in C:\Users\Shi Jie\Downloads\nginx-1.23.0\nginx-1.23.0/conf/nginx.conf:12"
i think it is how i write the path on my ngnix.conf which i write as such
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include \Users\Shi Jie\Downloads\nginx-1.23.0\nginx-1.23.0\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;
client_body_buffer_size 100k;
client_header_buffer_size 1k;
client_max_body_size 100k;
large_client_header_buffers 2 1k;
client_body_timeout 10;
client_header_timeout 10;
keepalive_timeout 5 5;
send_timeout 10;
server_tokens off;
#gzip on; on;
include /etc/nginx/conf.d/*.conf;
}
Can anyone point the way to teach me how to write the path properly? Thank you.
You need to escape spaces, { and ". So change your include line to the following:
...
include /Users/Shi\ Jie/Downloads/nginx-1.23.0/nginx-1.23.0/mime.types;
...
Related
I have a CentOS 8 (fedora) server running and I'm trying to run my Django Webapp on it through Nginx
It runs on port 8000, and I want to access it on my browser through nginx (so port 80?)
These commands on the server itself
This shows my webapp HTML page fine
curl http://127.0.0.1:8000
curl http://0.0.0.0:8000
but these show me the Nginx 502 Bad Gateway page
curl http://0.0.0.0
curl http://127.0.0.1
No errors in the nginx log files
This is my nginx.config:
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;
error_log /var/log/nginx/error.log;
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;
server_tokens off;
server {
listen 80;
server_name $hostname; # I tried this with an '_' also no help
location / {
proxy_pass http://0.0.0.0:8000; # also tried with 127.0.0.1
proxy_set_header Host $host;
}
}
}
Running
nginx -T shows the config has been loaded
Any advise on what to look for? (perhaps my firewall is blocking it somehow? idk)
Kind regards
I'm trying to get my webpage working through Nginx
Looks like it was a firewall issue, I needed to open the port to accept messages
iptables -I INPUT 1 -i eth0 -p tcp --dport 8000 -j ACCEPT
Below is my edited nginx.conf
user ec2-user;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 2048;
}
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;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
When I changed the user variable from nginx user to ec2-user, the logs are not getting captured in the /var/log/nginx/access.log file even though the file is present it always remains zero size
I've got a Django application running on Azure App Service using NGINX.
My nginx.conf file is as follow:
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;
keepalive_timeout 65;
fastcgi_max_temp_file_size 0;
fastcgi_buffers 128 2048k;
fastcgi_buffer_size 2048k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
server {
listen 8000;
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}
location /static {
alias /app/staticfiles;
}
}
}
daemon off;
Everything works fine, except for one particular API where I include in the header some token (typical bearer token) and it's returning a 502 error from Chrome (in the network tab)
However, when I try to call this from Postman, it's returning the data correctly.
What could be possibly wrong here?
Thanks to #Selcuk's suggestion. I've managed to fix the above error by increasing the buffer-size in iwsgi.ini file
# uwsgi.ini file
buffer-size = 32768
I have a django app where the hompage routes correctly, but when I try to click on any of the links I get a 404 error. I looked at the logs and see:
*1 open() "/usr/share/nginx/html/pricing" failed (2: No such file or directory)
which tells me that nginx is not looking at my project folder but instead what seems to be a default setting. I am using centos, so I had to manually setup sites-available and sites-enabled, which I have used to get the homepage working. As such there is no default conf to disable. I am unsure how to get nginx to route to my path instead of the default. My nginx.conf file looks like this:
user so_dev;
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 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; #added by me
}
I followed a bad tutorial which had a typo in it. If you happen to follow same type, inside your nginx sites-available file you should put:
location /
and NOT
location = /
https://www.shellvoide.com/hacks/installing-django-application-with-nginx-mysql-and-gunicorn-on-ubuntu-vps/
I have a centos server with nginx installed where i would to load a django app.
After install python34, nginx, django and gunicorn i configure nginx.conf file like this:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
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 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;
index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 54.17X.2XX.11X;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /static/ {
#alias /opt/cath/static/;
alias /home/ec2-user/test/endpoint/website/static/;
}
location / {
proxy_pass http://127.0.0.1:8000/site;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
well at this point, when i start gunicorn and nginx seervic for all the resource under /home/ec2-user/test/endpoint/website/static/ i receive the 403 forbidden access error.
I try with:
sudo chmod -R 777 <Path to static>
also tried with
sudo chown -R nginx:nginx <path to static>
but error 403 persist
How can i resolve this issue?
Thanks in advance
but the problem persist
i think it is related to SELinux you can disable it by:
nano /etc/selinux/config
change the value of SELINUX to disabled
location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; }