nginx常用配置文件
小于 1 分钟
nginx端口转发
server {
listen 80;
server_name www.123.com;
location / {
proxy_pass http://127.0.0.1:8080;
index index.html index.htm index.jsp;
}
}
nginx负载均衡
upstream guwenjie_http {
server **.***.***.***:9503 weight=1;
server **.***.***.***:8811 weight=2;
}
server
{
listen 80;
#listen [::]:80 default_server ipv6only=on;
server_name test1.freephp.top;
index index.php index.html index.htm ;
root /home/wwwroot/workspace/public/static;
#error_page 404 /404.html;
location / {
if (!-e $request_filename){
#proxy_pass http://127.0.0.1:8855;
proxy_pass http://guwenjie_http;
}
}
location /nginx_status
{
stub_status on;
access_log off;
}
}
nginx伪静态配置实例
location / {
proxy_pass http://162.14.72.65;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# try_files $uri $uri/ /index.php$is_args$query_string;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
proxy_pass http://162.14.72.65;
}
location ~ .*\.(js|css)?$
{
proxy_pass http://162.14.72.65;
}
nginx vue配置
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://127.0.0.1:8090;
proxy_redirect off;
proxy_set_header Host $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}