Background: I've installed and currently maintaining a OTRS v4.0 system with nginx as web server. The system was running until I added ssl port as well in nginx.conf and since then, I'm trying to connect to the webpage
http://localhost/otrs/index.pl
but is not responsive and displaying nginx error! The Page you are looking for is not found.
I removed the ssl sections from the nginx.conf file but still I'm not able to get back my previous state of web page.
In the error.log file it displays that it is not able to find the index.pl file open() "/usr/share/nginx/html/otrs/index.pl" failed (2: No such file or directory)
This message is logged whenever I hit the URL(http://localhost/otrs/index.pl).
In the otrs.log file it just logs in the PID.
Is there any way-out without having to re-install the otrs again? or any other log files I've missed to check
# 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;
events {
worker_connections 1024;
#debug_connection 10.0.2.15;
}
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;
server {
listen 80 default_server;
#listen 80;
server_name server.unixmen.local;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
?
Thanks in advance!
You have confused your default servers and nginx is trying to serve the wrong content.
OTRS uses fastcgi and will have it's own config file in the /etc/nginx/conf.d directory. The file you have posted is the default nginx config which has little to do with OTRS.
Change your listen directive to:
#listen 80 default_server;
listen 80;
This will discourage the default nginx config from handling unknown host connections to https://localhost and assuming it worked previously then the system should work again. If not then post the OTRS config from /etc/nginx/conf.d/something.conf and we'll be able to see what else is happening.
Thanks for your replies. I got the solution!
Perhaps, it was a silly mistake from my end ;)
First of all, I forgot to mention in the question that I also ran another web server on the same machine, Apache. At the initial stage, both the servers were configured at same port ->80. So, the OTRS was running on Apache instead of nginx(I'm using this as well for another purpose!). Later on, to avoid the confusion i changed the port in Apache configuration from 80 to 8080 and right from this moment the server stopped serving the OTRS.
So now, when I use http://localhost:8080/otrs/index.pl it's working correctly.
Next time, I would take enough care to change server configuration wisely while working on multiple web servers.
Related
I'm having the following issue :
My centos 7 vps is configured with nginx and two server-blocks (vhosts)
For both domains I can access the web-page using www.domain.tld but not using domain.tld.
No error or access logs are generated when accessing domain.tld
Dns record were checked and are pointing to the servers IP address with an empty A record ( the same dns record worked properly when server was configured with ubuntu 18.04, iRedMail, nextcloud and two websites).
The error message in browser is : "This site can’t be reached. domain.tld refused to connect."
Below are the config files (nginx and one domain), I've included the path for reference:
nginx.conf
#cat /etc/nginx/nginx.conf
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 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
server_names_hash_bucket_size 64;
server {
listen 80 default_server;
server_name "";
return 444;
}
}
* default_server is used to prevent access to nginx welcome page when accessing http:\serverIP . Behavior is not affected by returning this config to nginx default.
domain config
# cat /etc/nginx/sites-enabled/domain.tld.conf
server {
listen 80;
server_name domain.tld www.domain.tld;
location / {
root /var/www/domain.tld;
index index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# Setting log locations
access_log /var/log/nginx/domain.tld-access.log;
error_log /var/log/nginx/domain.tld-error.log debug;
}
I must mention that the purpose of this VPS is to learn basic Linux sysadmin, therefore there is no real data or restrictions and also that is my first contact with centos.
Thanks for your time and effort.
L.E.
Adding "127.0.0.1 www.domain.tld domain.tld" to /etc/hosts does not fix the issue. Both domains are real domains with dns server and all records are replicated. Furthermore using trace-route to domain VPS IP is reached.
Nginx config is successful validated
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Upon further investigations I've noticed that no request appear in access or error log (error set to debug) when accessing domain.tld but they do for www.domain.tld
Witch would send me straight to DNS but checking DNS using a few dig online versions everything seems OK, both domain.tld and www.domain.tld point to the correct VPS ip
After loosing almost two days trying to figure out what is causing this issue finally, non-intentionally I've accessed the website while I was remote on another PC and to my utmost surprise everything worked just fine.
Now I'm sure that I've cleared my DNS cache multiple times but apparently the issue was generated by plugin httpsEverywhere.
Thanks and I promise to try harder next time :D
I have one domain myartistbook.in, which is working fine. I want to create a sub-domain for it named adminpanel.myartistbook.in. The steps I followed are:
Added sub-domain name to /etc/hosts
127.0.0.1 localhost
***.***.***.180 myartistbook
***.***.***.180 adminpanel.myartistbook
edited /etc/nginx/nginx.conf:
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 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name myartistbook.in www.myartistbook.in;
root /root/krim.com;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 80;
root /root/sites/adminpanel.com;
server_name adminpanel.myartistbook.in www.adminpanel.myartistbook.in;
index index.html;
location / {
try_files $uri $uri/;
}
}
}
Added a file named adminpanel.com inside /etc/nginx/sites-available.
server {
listen 80;
server_name www.adminpanel.myartistbook.in;
server_name ***.***.***.180;
root /root/sites/adminpanel.com;
index index.html;
access_log /var/log/nginx/adminpanel.com.access.log;
error_log /var/log/nginx/adminpanel.com.error.log;
location / {
try_files $uri /index.html =404;
}
}
Linked the above server block into /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/adminpanel.com /etc/nginx/sites-enabled/adminpanel.com
Restarted nginx with
sudo service nginx restart
While accessing the site I'm getting error adminpanel.myartistbook.in’s server IP address could not be found.
Am I missing any step?
Together with server-side configurations involving domains and subdomains in server_name, you need to make sure that your DNS records for myartistbook.in are properly configured as well.
Have you added a DNS record to point adminpanel.myartistbook.in to your server? You can either add an A record or a CNAME record for this. Looking at a quick check using whatsmydns.net for adminpanel.myartistbook.in, it seems you missed this step. Please check the documentation of your domain registrar on how to do this.
After adding the records, do a quick check again using whatsmydns.net if your CNAME/A record has taken effect.
In your step 3, modify the server_name to adminpanel.myartistbook.in without the www, unless this is actually your intention to use the whole www.adminpanel.myartistbook.in, which I don't think is the case here because you attempted to access it without the www:
adminpanel.myartistbook.in’s server IP address could not be found.
Also, it's probably good to use a different server {} block when referring to IP addresses as server_name then redirect to the domain/subdomain. However, redirecting from IP Address going to your domain/subdomain may be not be the priority now. Suggest to remove that line in the meantime.
Then run a quick nginx -T to check for errors in your configuration. If the check is successful, reload your nginx web server and try accessing the subdomain again.
Hope that helps!
It seems like a simple problem but I cannot find any official information about how to fix it.
The problem: Deploying an EmberJS app to Nginx - all routes return 404's.
The root route / works just fine. However any route besides / fails & returns 404's. Here's how I have my nginx.conf setup:
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 {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/ivo/myapp;
index index.html;
location / {
include /etc/nginx/mime.types;
try_files $uri $uri/ /index.html?/$request_uri;
}
}
}
This config is largely based on the nginx.conf that comes with the Nginx Docker image, which I am using.
From what I understand about Nginx, the location / block should be handling my routes, but for some reason it is not.
As a side note, I am shocked that EmberJS does not have any documentation about this at all. I even tried their Nginx config from their deployment section and it too did not work - https://ember-cli.com/user-guide/#deployments
Found & "fixed" the problem. The underlying issue is that the information provided on the Nginx DockerHub page is misleading. It says:
"If you wish to adapt the default configuration, use something like the following to copy it from a running nginx container"
And it provides this line as an example:
"COPY nginx.conf /etc/nginx/nginx.conf"
However, the file located at /etc/nginx/nginx.conf was not the file I needed. Instead, the file I needed to change/replace was located here : "/etc/nginx/conf.d/default.conf"
The code I pasted above in the Question portion worked fine; it was the location that was wrong.
I have a CentOS 7 server where I have running some Golang apps. As you know, every app is running on his own port, lets say: 9000,9100,9200 and so on.
Now, I have installed Nginx to serve all the websites, I have a domain for every site and I want to receive all the petitions in the port 80 and then just based on the domain i have to redirect to the application that corresponds.
By now,am trying to make it with one of the site that is running in the port 9094, I have no experience with Nginx so I was just reading to know what to do,but it seems like it's not working. in the file nginx.conf I added these lines:
server {
listen 80;
server_name mydomain.com;
access_log logs/mydomain.log main;
location / {
proxy_pass http://127.0.0.1:9094;
}
}
I have to mention that I didn't delete these lines that comes for default in the file:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Is the configuration ok? and will allow me to add more sites? Thank you
If I ping to the domain everything is ok, but if I open the domain in the browser then I get status code 502
EDIT:
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;
server {
listen 80;
server_name mydomain.com;
access_log logs/mydomain.log main;
location / {
proxy_pass http://127.0.0.1:9094;
}
}
}
Your server configuration looks okay and the 502 Status Code means you didn't configure the Go servers correctly. Specifically, Nginx did exactly what you expected it to, proxied the request to and from your upstream, but received an invalid response from your Go server.
I've tried everything and i can't still get to display errors on the browser, I'm using nginx, php-fpm and centOS 6.4
nginx.conf
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;
}
this is my nginx config inside conf.d
server {
listen 80;
server_name localhost;
root /server/public;
index run.php;
location / {
try_files $uri $uri/ /run.php;
}
location ~ \.php$ {
fastcgi_index run.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
php-fpm config
catch_workers_output = yes
php_flag[display_errors] = on
php_admin_flag[log_errors] = on
php.ini
display_errors = on
log_errors = on
I'm running CentOS 6.4 on virtualbox with NAT enabled, if i curl localhost from inside the server i get the correct error but if i access the site from the browser outside of the server i get a 502 bad gateway error, if the page I'm loading has no errors everything works fine, am I missing anything?
If you're wondering why you were getting that error I could give you few hints.
error 502 means bad gateway, means that the php server that nginx was trying to proxy to wasn't responding, maybe because php5-fpm wasn't listening to port 9000 and it was using a sock file instead, or could be that php wasn't running at all(if all php files aren't working)
Why did you get different responses from curl and the browser?, well because your server is defined as localhost I'm assuming both methods were not being captured by different server blocks.
The correct method to have fixed this is to check the active virtual hosts, and the php5-fpm listen config,
I think it's just coincidence that install the new php fixed the issue probably because it overwritten the old config file to a new one that worked with the nginx config.
But anyway, I was just trying to give you some hints of what to check if you ever find a similar problem in the future.
Looks like it was my version of php (5.3) that was failing, after updating to php 5.5 it started working