This configuration works with multiple virtual hosts, and allows the images for all pages to be in an images directory.
worker_processes 2; # One for each CPU core
error_log logs/main_error.log;
pid logs/nginx.pid;
events { worker_connections 1024; }
http
{ include mime.types;
# i.e. On Windows, [<nginx>/conf/]mime.types
# i.e. the mime.types file in the conf dir in the nginx's directory
default_type application/octet-stream;
index index.htm index.html index.st index.php;
# the file provided when a client asks for a directory
server #default
{ server_name :80;
access_log logs/catchall.access.log;
error_log logs/catchall.error.log;
root html\catchall;
}
server #Server_1
{ server_name Server_1.uk.to ; # *.Server_1.uk.to;
access_log logs/Server_1.access.log;
error_log logs/Server_1.error.log;
root html/Server_1/currentSite;
location ^~ /images/ { alias html/Server_1/images/; }
}
server #Server_2
{ server_name Server_2.uk.to ; # *.Server_2.uk.to;
access_log logs/Server_2.access.log;
error_log logs/Server_2.error.log;
root html/Server_2/currentSite;
location ^~ /images/ { alias html/Server_2/images/; }
}
}
Showing posts with label nginx. Show all posts
Showing posts with label nginx. Show all posts
Tuesday, 5 February 2013
Thursday, 31 January 2013
Stage 2 - Discover nginx data must be in a subdirectory of nginxSet up nginx on Windows virtual hosts for multiple domain names
I next put in multiple virtual hosts.
I made the mistake of referring to the files off in absolute paths elsewhere in the PC
It seemed to work - but only sometimes... The pictures would not appear - or would only appear on the first call. Further web-page requests after that might be text-only, or might just hang forever.
Returning the locations to be subdirectories of the <nginx>/html directory fixed all the problems.
I made the mistake of referring to the files off in absolute paths elsewhere in the PC
It seemed to work - but only sometimes... The pictures would not appear - or would only appear on the first call. Further web-page requests after that might be text-only, or might just hang forever.
Returning the locations to be subdirectories of the <nginx>/html directory fixed all the problems.
Stage 1 - Set up nginx on Windows, with ZoneAlarm
Ultimately, my plan is to use nginx to serve the static web pages for multiple domain names, and for it to act as a reverse-proxy to the Seaside web-apps.
Stage 1 - get nginx working, and visible from the internet.
Step 1 - get nginx (pronounced "Engine X") working on Windows.
At the Command Line (Run cmd from Start Menu), cd <the folder containing the application app>
type nginx
On Vista, it works with three processes, all called "nginx" with Process Ids (PIDs) listed by:
tasklist /FI "IMAGENAME eq nginx*"
Notes: It sets up using the parameters contained in the nginx.conf file held in
<the folder containing the nginx application> /conf
This nginx.conf file provides a webserver on port 80.
worker_processes 2; # One for each CPU core
error_log logs/main_error.log;
pid logs/nginx.pid;
events { worker_connections 1024; }
http
{ include mime.types;
# On Windows, this goes to [<nginx>/conf/]mime.types
# i.e. the mime.types file in the conf dir in the nginx's directory
default_type application/octet-stream;
index index.htm index.html index.st index.php;
server #default
{ server_name :80;
access_log logs/catchall.access.log;
error_log logs/catchall.error.log;
root html\catchall;
}
}
Step 2 - close down nginx on Windows
run cmd from Start Menu again, to bring up a second Command Line
(As the cmd window opened in step 1 gets taken over by nginx, so cannot be used)
nginx -s stop
If nginx has had a problem with the configuration file, this sometimes might not work.
First alternative:
nginx -s quit
If this also does not work, the second alternative:
Find the PIDs for the principal nginx process on Window
tasklist /FI "IMAGENAME eq nginx*"
Kill the processes
taskkill /PID <number in the nginx.pid file>
Step 3 get nginx visible through the router's firewall.
Make sure the PC running nginx has a static IP address.
Log into the router, and use port-forwarding for HTTP on port 80, to the PC.
Step 4 Get nginx working through ZoneAlarm Free firewall
Check if the server is accessible from outside your local network. (A good way is to switch off wifi on your phone, and then use the phone's browser to access the website via the website's domain name).
If it works, that's great.
If it doesn't work however...
Switch off ZoneAlarm Free Firewall.
Check if the server is accessible from outside your local network.
If it still doesn't work ...
Re-check that the web-server is running: tasklist /FI "IMAGENAME eq nginx*"
Re-check what IP address the PC is on, and that it matches the IP being used on the router's port-forward. (Also check that it matches the static IP address that you want the PC to use).
If the server is accessible, switch ZoneAlarm back on.
Delete nginx from the list of programmes in ZoneAlarm
Try to access the webserver via localhost
and try to access the webserver from another local device via the IP address.
Zonealarm will pop up a window asking if nginx should be allowed to provide local access.
Check if the server is accessible from outside.
Zonealarm will pop up a window asking if nginx should be allowed to provide access to the internet.
Stage 1 - get nginx working, and visible from the internet.
Step 1 - get nginx (pronounced "Engine X") working on Windows.
At the Command Line (Run cmd from Start Menu), cd <the folder containing the application app>
type nginx
On Vista, it works with three processes, all called "nginx" with Process Ids (PIDs) listed by:
tasklist /FI "IMAGENAME eq nginx*"
Notes: It sets up using the parameters contained in the nginx.conf file held in
<the folder containing the nginx application> /conf
This nginx.conf file provides a webserver on port 80.
worker_processes 2; # One for each CPU core
error_log logs/main_error.log;
pid logs/nginx.pid;
events { worker_connections 1024; }
http
{ include mime.types;
# On Windows, this goes to [<nginx>/conf/]mime.types
# i.e. the mime.types file in the conf dir in the nginx's directory
default_type application/octet-stream;
index index.htm index.html index.st index.php;
server #default
{ server_name :80;
access_log logs/catchall.access.log;
error_log logs/catchall.error.log;
root html\catchall;
}
}
Step 2 - close down nginx on Windows
run cmd from Start Menu again, to bring up a second Command Line
(As the cmd window opened in step 1 gets taken over by nginx, so cannot be used)
nginx -s stop
If nginx has had a problem with the configuration file, this sometimes might not work.
First alternative:
nginx -s quit
If this also does not work, the second alternative:
Find the PIDs for the principal nginx process on Window
tasklist /FI "IMAGENAME eq nginx*"
Kill the processes
taskkill /PID <number in the nginx.pid file>
Step 3 get nginx visible through the router's firewall.
Make sure the PC running nginx has a static IP address.
Log into the router, and use port-forwarding for HTTP on port 80, to the PC.
Step 4 Get nginx working through ZoneAlarm Free firewall
Check if the server is accessible from outside your local network. (A good way is to switch off wifi on your phone, and then use the phone's browser to access the website via the website's domain name).
If it works, that's great.
If it doesn't work however...
Switch off ZoneAlarm Free Firewall.
Check if the server is accessible from outside your local network.
If it still doesn't work ...
Re-check that the web-server is running: tasklist /FI "IMAGENAME eq nginx*"
Re-check what IP address the PC is on, and that it matches the IP being used on the router's port-forward. (Also check that it matches the static IP address that you want the PC to use).
If the server is accessible, switch ZoneAlarm back on.
Delete nginx from the list of programmes in ZoneAlarm
Try to access the webserver via localhost
and try to access the webserver from another local device via the IP address.
Zonealarm will pop up a window asking if nginx should be allowed to provide local access.
Check if the server is accessible from outside.
Zonealarm will pop up a window asking if nginx should be allowed to provide access to the internet.
Labels:
cmd,
configuration,
firewall,
nginx,
port forwarding,
taskkill,
tasklist,
Windows,
ZoneAlarm
Subscribe to:
Posts (Atom)