Nginx: Failed to start A high performance web server and a reverse proxy server

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
3
down vote

favorite
1












I recently tried to install letsencrypt certificate, but I couldn't start nginx again. when I run the command service nginx status. I get this error message



 nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:
enabled)
Active: failed (Result: exit-code) since Tue 2018-02-20 16:17:49 CET; 8min
ago
Process: 1439 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on;
master_process on; (code=exited, status=1/FAILURE)

Feb 20 16:17:47 django-s-1vcpu-1gb-lon1-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:87
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Unit entered failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Failed with result 'exit-code'.


And here is /etc/nginx/sites-avalible/django



upstream app_server 
server unix:/home/django/gunicorn.socket fail_timeout=0;


server
#listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;

listen 443 ssl;
server_name nettside.no;
ssl_certificate /etc/letsencrypt/live/nettside.no/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nettside.no/privkey.pem;

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

client_max_body_size 4G;
server_name nettside.no;

keepalive_timeout 5;

# Your Django project's media files - amend as required
location /media
alias /home/django/django_project/django_project/media;


# your Django project's static files - amend as required
location /static
alias /home/django/django_project/static;


# Proxy the static assests for the Django Admin panel
location /static/admin
alias /home/django/django_project/static/admin;



location /
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;

proxy_pass http://app_server;




server
listen 80;
server_name nettside.no;
return 301 https://$host$request_uri;



Thanks for the help.










share|improve this question





















  • The error messages reads "location" directive is not allowed here in /etc/nginx/nginx.conf:87. There is a configuration error in the nginx.conf file on line 87. Please check yourself or paste nginx.conf here.
    – Bob
    Feb 22 at 16:35










  • Thank you for answering. The problem was that i had a lovation i my nginx.conf file
    – ranjith
    Feb 22 at 16:37














up vote
3
down vote

favorite
1












I recently tried to install letsencrypt certificate, but I couldn't start nginx again. when I run the command service nginx status. I get this error message



 nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:
enabled)
Active: failed (Result: exit-code) since Tue 2018-02-20 16:17:49 CET; 8min
ago
Process: 1439 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on;
master_process on; (code=exited, status=1/FAILURE)

Feb 20 16:17:47 django-s-1vcpu-1gb-lon1-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:87
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Unit entered failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Failed with result 'exit-code'.


And here is /etc/nginx/sites-avalible/django



upstream app_server 
server unix:/home/django/gunicorn.socket fail_timeout=0;


server
#listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;

listen 443 ssl;
server_name nettside.no;
ssl_certificate /etc/letsencrypt/live/nettside.no/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nettside.no/privkey.pem;

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

client_max_body_size 4G;
server_name nettside.no;

keepalive_timeout 5;

# Your Django project's media files - amend as required
location /media
alias /home/django/django_project/django_project/media;


# your Django project's static files - amend as required
location /static
alias /home/django/django_project/static;


# Proxy the static assests for the Django Admin panel
location /static/admin
alias /home/django/django_project/static/admin;



location /
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;

proxy_pass http://app_server;




server
listen 80;
server_name nettside.no;
return 301 https://$host$request_uri;



Thanks for the help.










share|improve this question





















  • The error messages reads "location" directive is not allowed here in /etc/nginx/nginx.conf:87. There is a configuration error in the nginx.conf file on line 87. Please check yourself or paste nginx.conf here.
    – Bob
    Feb 22 at 16:35










  • Thank you for answering. The problem was that i had a lovation i my nginx.conf file
    – ranjith
    Feb 22 at 16:37












up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





I recently tried to install letsencrypt certificate, but I couldn't start nginx again. when I run the command service nginx status. I get this error message



 nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:
enabled)
Active: failed (Result: exit-code) since Tue 2018-02-20 16:17:49 CET; 8min
ago
Process: 1439 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on;
master_process on; (code=exited, status=1/FAILURE)

Feb 20 16:17:47 django-s-1vcpu-1gb-lon1-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:87
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Unit entered failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Failed with result 'exit-code'.


And here is /etc/nginx/sites-avalible/django



upstream app_server 
server unix:/home/django/gunicorn.socket fail_timeout=0;


server
#listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;

listen 443 ssl;
server_name nettside.no;
ssl_certificate /etc/letsencrypt/live/nettside.no/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nettside.no/privkey.pem;

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

client_max_body_size 4G;
server_name nettside.no;

keepalive_timeout 5;

# Your Django project's media files - amend as required
location /media
alias /home/django/django_project/django_project/media;


# your Django project's static files - amend as required
location /static
alias /home/django/django_project/static;


# Proxy the static assests for the Django Admin panel
location /static/admin
alias /home/django/django_project/static/admin;



location /
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;

proxy_pass http://app_server;




server
listen 80;
server_name nettside.no;
return 301 https://$host$request_uri;



Thanks for the help.










share|improve this question













I recently tried to install letsencrypt certificate, but I couldn't start nginx again. when I run the command service nginx status. I get this error message



 nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:
enabled)
Active: failed (Result: exit-code) since Tue 2018-02-20 16:17:49 CET; 8min
ago
Process: 1439 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on;
master_process on; (code=exited, status=1/FAILURE)

Feb 20 16:17:47 django-s-1vcpu-1gb-lon1-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:87
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 nginx[1439]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Unit entered failed
Feb 20 16:17:49 django-s-1vcpu-1gb-lon1-01 systemd[1]: nginx.service: Failed with result 'exit-code'.


And here is /etc/nginx/sites-avalible/django



upstream app_server 
server unix:/home/django/gunicorn.socket fail_timeout=0;


server
#listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;

listen 443 ssl;
server_name nettside.no;
ssl_certificate /etc/letsencrypt/live/nettside.no/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nettside.no/privkey.pem;

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

client_max_body_size 4G;
server_name nettside.no;

keepalive_timeout 5;

# Your Django project's media files - amend as required
location /media
alias /home/django/django_project/django_project/media;


# your Django project's static files - amend as required
location /static
alias /home/django/django_project/static;


# Proxy the static assests for the Django Admin panel
location /static/admin
alias /home/django/django_project/static/admin;



location /
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;

proxy_pass http://app_server;




server
listen 80;
server_name nettside.no;
return 301 https://$host$request_uri;



Thanks for the help.







nginx






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 20 at 15:35









ranjith

1612




1612











  • The error messages reads "location" directive is not allowed here in /etc/nginx/nginx.conf:87. There is a configuration error in the nginx.conf file on line 87. Please check yourself or paste nginx.conf here.
    – Bob
    Feb 22 at 16:35










  • Thank you for answering. The problem was that i had a lovation i my nginx.conf file
    – ranjith
    Feb 22 at 16:37
















  • The error messages reads "location" directive is not allowed here in /etc/nginx/nginx.conf:87. There is a configuration error in the nginx.conf file on line 87. Please check yourself or paste nginx.conf here.
    – Bob
    Feb 22 at 16:35










  • Thank you for answering. The problem was that i had a lovation i my nginx.conf file
    – ranjith
    Feb 22 at 16:37















The error messages reads "location" directive is not allowed here in /etc/nginx/nginx.conf:87. There is a configuration error in the nginx.conf file on line 87. Please check yourself or paste nginx.conf here.
– Bob
Feb 22 at 16:35




The error messages reads "location" directive is not allowed here in /etc/nginx/nginx.conf:87. There is a configuration error in the nginx.conf file on line 87. Please check yourself or paste nginx.conf here.
– Bob
Feb 22 at 16:35












Thank you for answering. The problem was that i had a lovation i my nginx.conf file
– ranjith
Feb 22 at 16:37




Thank you for answering. The problem was that i had a lovation i my nginx.conf file
– ranjith
Feb 22 at 16:37















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1008078%2fnginx-failed-to-start-a-high-performance-web-server-and-a-reverse-proxy-server%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1008078%2fnginx-failed-to-start-a-high-performance-web-server-and-a-reverse-proxy-server%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Which professions warranted travel in Medieval times?

How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

Trouble downloading packages list due to a “Hash sum mismatch” error