博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux:nginx配置示例
阅读量:7299 次
发布时间:2019-06-30

本文共 1481 字,大约阅读时间需要 4 分钟。

hot3.png

支持PHP

配置文件

一般放在/etc/nginx/sites-available中,若要启用某配置文件,需要将其链接到/etc/nginx/sites-enabled/

静态网站

需要将域名static-site.domain.com指向主机的IP。

/etc/nginx/sites-enabled/static-site.conf:

server {    listen   80; ## listen for ipv4; this line is default and implied    listen   [::]:80 default ipv6only=on; ## listen for ipv6    server_name static-site.domain.com;    root //path/to/static-site/;        location ~.*\.(ico|css|js|gif|jpe?g|png)$ {        expires 2d;    }    location / {        index index.html index.htm;        error_page 404 /error.html;        expires  2h;    }}

Ghost博客

/etc/nginx/sites-enabled/ghost.conf:

配置Ghost监听本地的2368端口。

upstream ghost {    server 127.0.0.1:2368;}server {    listen 80;    server_name ghost.domain.com;    server_name_in_redirect  off;    access_log  off;    error_log /path/to/ghost/nginx-error.log;    # Allow file uploads    client_max_body_size 1M;    proxy_read_timeout 10;    location / {        proxy_pass_header Server;        proxy_set_header Host $http_host;        proxy_redirect off;        proxy_set_header X-Real-IP $remote_addr;        proxy_set_header X-Scheme $scheme;        proxy_pass http://ghost;    }}

通过IP访问时候自动转到某域名

如从 122.122.122.122 自动转到 www.domain.com 。

server {    listen   80; ## listen for ipv4; this line is default and implied    listen   [::]:80 default ipv6only=on; ## listen for ipv6    server_name 122.122.122.122;    return 301 $scheme://www.domain.com$request_uri;}

转载于:https://my.oschina.net/letiantian/blog/630573

你可能感兴趣的文章
$().each()和$.each()
查看>>
iconfont字体图标
查看>>
AndroidStudio下加入百度地图的使用 (三)——API基本方法及常量属性
查看>>
二、2、上传成功也不一定得到flag哦!
查看>>
火狐浏览器设置placeholder的时候记得改opacity
查看>>
Mina学习
查看>>
java通过句柄访问对象
查看>>
extern "C"与C++中的C函数调用(4)—— 如何在C中调用C++函数
查看>>
计算几何 模板
查看>>
“The Psychology of Cross Country”笔记
查看>>
10 Web Apps for Developers 为开发者提供的10款Web应用程序
查看>>
python之正则表达式
查看>>
Shell命令-文件及目录操作之touch、tree
查看>>
修改K/3 Cloud管理中心端口
查看>>
C#语言课程11月7日
查看>>
linux日常1-踢出用户
查看>>
MFC多文档应用程序同时显示两个视图
查看>>
github快速入门(一)
查看>>
PHP全栈开发(八):CSS Ⅸ dispaly & visibility
查看>>
正则表达式
查看>>