Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am using nginx for the first time and I cannot find why I cannot get it going under Debian 9.
I am trying to test plain html files located on a Linode before assigning DNS records which seems to be the conventional way of testing without giving world access to the files. When I ssh to the Linode IP address, I can see all the files and read them with nano.
I have tried to have the "server blocks" in
/etc/nginx/conf.d
and then move them to
/etc/nginx/sites-available
with symlinks in sites-enabled, in both cases, the config files are found to be correct.
I tried /etc/hosts:
ip_address hostname.mydomain.tld
and
ip_address mydomain.tld
ip_address www.mydomain.tld
The results are invariably a long "waiting for ip_address" followed by "connection reset...." although at one stage I got a 404 on index.html but I could not isolate the difference in the code.
It seems the problem is with the hosts file or hostname or both which seem to me to have correct values.
I simply cannot find a tutorial or howto on this specific subject.
First you should simply try from the same computer:
It works perfectly on the home computer either "clicking" index.html or through the server (apache2) "http://127.0.0.1/index.html" and trying your "wget" suggestion
Quote:
Check the logs and maybe post errors here, so we could help you
/var/log/nginx/ access log and error log have 0 byte although tries from previous days have lines of "...signal process started"
It seems nginx fails before being able to report anything wrong and it's not my connection since I can access LQ.
It works perfectly on the home computer either "clicking" index.html or through the server (apache2) "http://127.0.0.1/index.html" and trying your "wget" suggestion
/var/log/nginx/ access log and error log have 0 byte although tries from previous days have lines of "...signal process started"
It seems nginx fails before being able to report anything wrong and it's not my connection since I can access LQ.
This actually tells you that nginx is working, assuming you ran the wget command as instructed (i.e. on the Linode).
Do you have any reason to think that it mysteriously fails before writing an error log, or is that a product of imagination?
You most likely do not have nginx configured to listen on your Linode's IP address, or your firewall is not configured to allow traffic on port 80.
Can you post the appropriate parts of your nginx configuration (obscure the IP address if desired).
Also please post the output of iptables -L INPUT, or other relevant firewall rules.
In case you have not seen it here is a Linode page with relevant nginx configuration info. Make sure your server port/IP and names are properly defined, and that your server name is in your hosts file, restart nginx.
Last edited by astrogeek; 09-18-2019 at 12:30 AM.
Reason: Added Linode link.
This actually tells you that nginx is working, assuming you ran the wget command as instructed (i.e. on the Linode).
No, I ran it on my home machine - trying to rush a bit too much and thinking the post was all about my own machine. Trying it on the Linode gives the following result:
Code:
Connecting to 127.0.0.1:80... failed: Connection refused.
I have meticulously followed Linode's instructions and after a few days of unsuccessful attempts, purge nginx and reinstalled from the same instructions.
Here is the main config from /etc/nginx/nginx.conf
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-09-17 22:43:42 AWST; 23h ago
Docs: http://nginx.org/en/docs/
Process: 31191 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 31194 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 31195 (nginx)
Tasks: 3 (limit: 4915)
CGroup: /system.slice/nginx.service
├─31195 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
├─31196 nginx: worker process
└─31197 nginx: worker process
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
In addition to possibly not running nginx process, I see no actual handling for HTTP in the firewall rules (although UFW rules can be difficult to follow). It looks to me as if HTTP/HTTPS requests would end up at the end of the INPUT chain and would default to the DROP policy handler - so even if nginx were running you cannot reach it from outside.
I agree that what you need is unix server admin help as this is not a programming problem. If you would like to request that your question be moved to Linux Server or other forum please use the Report button to request that.
Thank you for the suggestions which I have followed. I am a bit more familiar with Apache2 and find Nginx far more complicated, perhaps erroneously, would I have a better chance of success moving to Apache2 or am I likely to face similar problems?
Thank you for the suggestions which I have followed. I am a bit more familiar with Apache2 and find Nginx far more complicated, perhaps erroneously, would I have a better chance of success moving to Apache2 or am I likely to face similar problems?
I too have more experience with Apache, although I do not generally find nginx to be overly confusing.
The problems you seem to be having are not really nginx specific, so you would likely have them with Apache as well. For example, the firewall rules are independent of the web server being used and will need to allow HTTP/S requests to pass no matter what web server is in use. And any webserver must be configured to listen on the external interface and proper port numbers or incoming traffic cannot reach it. The configuration syntax and file locations may differ, but the "thing" being configured is ultimately the same for all.
You also need to approach such problems in a more structured way, somewhat like the path this thread has taken. That is, you first should determine unambiguously whether or not the web server is actually running, ps being an obvious choice, and verify startup and error messages in the log.
Once you know it is running, check what it is listening to for incoming requests, lsof or netstat are helpful here.
Once you know it is running and listening, verify firewall rules are in place to allow incoming requests through, and if not add those rules.
At this point you should receive a response from the server, either a page or an error message.
The point of seeking unix admin help is that all these are basic skills and structured troubleshooting methods which any unix admin would do more or less automatically and quickly. Building those skills and thought processes are very important to anyone running a web facing server.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.