Created
May 9, 2017 08:59
-
-
Save prasanjit-/2f6f11c315341d869b8327169db71677 to your computer and use it in GitHub Desktop.
Nginx as a Web Server & Webproxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Nginx :: | |
NGINX is a free, open-source, high-performance HTTP server and reverse proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. | |
Installation: | |
yum install nginx | |
systemctl start nginx | |
Case 1: | |
Nginx as a Web Server: | |
Config file is in /etc/nginx/nginx.conf | |
### | |
server { | |
listen 80 default_server; ### Port | |
listen [::]:80 default_server; | |
server_name _; | |
root /usr/share/nginx/html; ### Document Root | |
# Load configuration files for the default server block. | |
include /etc/nginx/default.d/*.conf; ### Additional configs | |
location / { | |
} | |
error_page 404 /404.html; | |
location = /40x.html { | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
} | |
### | |
Case 2: | |
Nginx as Reverse Proxy: | |
Create a file say, /etc/nginx/conf.d/proxy_jenkins.conf with following content: | |
### | |
server { | |
listen 81; | |
server_name foobar.net; | |
location / { | |
proxy_pass http://127.0.0.1:8080; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
} | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment