nginx

NGINX 设置缓存时间

穿精又带淫゛_ 提交于 2021-02-05 13:56:39
设置缓存原因 一般的web项目,如果是前后不分离,采用模板生成页面的话,可以灵活控制 js,css等静态文件的版本号。来避免浏览器缓存的问题 但是目前是前后分离了,虽然前端发版都每次指定了版本号,但是发现有时候发版的时候,还是因为浏览器缓存导致了查看页面有时候出点小问题。 因此为了避免浏览器缓存可能导致的问题,因此 严谨一点 NGINX设置 一下 缓存时间还是很有必要的。 不能缓存太短,会造成服务器压力。 NGINX 设置缓存时间 expires location / { root html/dist; index index.html index.htm; try_files $uri $uri/ /index.html; expires 1d; } 参考 https://blog.csdn.net/qq_39642801/article/details/103713994 来源: oschina 链接: https://my.oschina.net/ouminzy/blog/4946344

nginx - rewriting index.php?hello=x to index/hello/x

南楼画角 提交于 2021-02-05 11:52:31
问题 How can I rewrite index.php?question=x to index/question/x using nginx and make index.php?question=x return 404 not found (if possible) and completely remove .php file extension from URLs I'm sure all of this has been covered somewhere but I have trouble understanding the rewrites on the nginx site. 回答1: You can't make index.php return a 404 error if index.php actually exists and you want to be rewriting to it. Both this ... rewrite ^index/question/(.*)$ /index.php?question=$1 last; location

记第一次使用NET CORE 2.2 完成的DEMO部署在LINUX并且上线

ⅰ亾dé卋堺 提交于 2021-02-05 09:25:11
.NET CORE 这么久了一直没有成功打通过,今天花了点儿时间做了一个小DEMO,首次完成并且部署上线。记录一下。 DEMO中只是测试了一下从MSSQL中获取数据,并且显示在页面上,涉及到了数据库连接,以及相关的部署步骤。一直到域名绑定。 最终上线的网址: http://test.core.68weitang.cn/ 因服务器过一段时间即到期,该网址有可能无法访问,相关源代码附在最后。 项目结构图: 引用了Business类库项目,Business业务层实现具体的业务,这个项目只做了连接MSSQL数据库,随机获取10条数据,转换成List<AccountVO>的对象。 Layouts项目就是调用Business业务层获取数据列表。代码如下: 后台代码。 代码完成之后,发布即可。 整个代码部分的工作就完成了,接着咱们来做部署方面的工作。 测试的服务器是阿里云的一台最低配置的ECS,1个CPU,500M内存,系统装的是CentOS 7.6的版本。 之前一直在安装linux的环境上面有很大的问题,上传文件要装XFTP,WEB服务器要使用nginx等,对于没怎么深入玩过LINUX的人,很头疼。后来发现宝塔这个软件非常好用,强烈推荐,安装也比较简单。 官方文档地址: https://www.bt.cn/bbs/thread-19376-1-1.html,其实就一个命令就行了,非常简单

react native app with nodejs as my backend and postgres as my database

本小妞迷上赌 提交于 2021-02-05 09:23:07
问题 I have successfully connected my nodejs backend and my PostgreSQL database to my ubuntu server. I have also installed nginx as a reverse proxy and it is working when i access the public ip address on the browser. When i cd to my backend folder that contains my index.js and do sudo node index.js: i get Server started on port 9000... Executing (default): SELECT 1+1 AS result Database Connected... and on my IOS simulator, my posts and everything get loaded correctly. My problem is when i close

Nginx allow via Domain but not via the IP

纵然是瞬间 提交于 2021-02-05 08:42:18
问题 This is my configuration: server { listen 80; listen [::]:80; server_name domain.tld www.domain.tld; return 301 https://erp.uni.mk$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name domain.tld; ssl_certificate "/etc/nginx/ssl/ca_full.crt"; ssl_certificate_key "/etc/nginx/ssl/private.key"; ... } What I am trying to achieve is block access via the IP. And only allow it via the domain. I've seen some solutions with regex, but I am using both IPv4 and IPv6. And

Node+Express+NGINX application returning localhost instead of domain

ⅰ亾dé卋堺 提交于 2021-02-05 08:33:07
问题 I have a node+express website running on my ubuntu server on port 10000 with nginx on port 80 using a proxy_pass to localhost:10000. My issue is that when I ask for the host in express it returns localhost instead of my domain name. I use the nginx proxy so I can manage several domains on the machine pointing to different applications. Is there a way to keep the original host name on my node+express server while still using proxy_pass in nginx? 回答1: By default, nginx sets the Host header in

react app showing empty page when redirecting on production build

半世苍凉 提交于 2021-02-05 06:42:46
问题 I have a reactJs app which is running on a server that has nginx on it. The problem is that when I try to redirect from HomePage("/") to /UserPanel or /AdminPanel the url changes but it shows an empty page, but then when i reload the page, it works just fine. This problem doesn't occur in my localhost, but it happens to the production build. this is my nginx config: listen 80 default_server; listen [::]:80 default_server; root /var/app/html; index index.html index.htm; location / { try_files

Nginx auth_request handler accessing POST request body?

左心房为你撑大大i 提交于 2021-02-04 17:29:26
问题 I'm using Nginx (version 1.9.9) as a reverse proxy to my backend server. It needs to perform authentication/authorization based on the contents of the POST requests. And I'm having trouble reading the POST request body in my auth_request handler. Here's what I got. Nginx configuration (relevant part): server { location / { auth_request /auth-proxy; proxy_pass http://backend/; } location = /auth-proxy { internal; proxy_pass http://auth-server/; proxy_pass_request_body on; proxy_no_cache "1"; }

服务网关配置:Zuul

一曲冷凌霜 提交于 2021-02-04 12:54:39
目录 第一章 Zuul介绍 1.1、什么是Zuul 1.2、为啥用Zuul 第二章 Zuul路由功能 2.1、项目准备与启动 2.2、工程搭建与测试 2.3、配置自定义路由 2.4、禁止默认的路由 2.5、简化自定义路由 2.6、统一加路径前缀 2.7、路由规则通配符 第三章 Zuul过滤功能 3.1、过滤器介绍 3.2、过滤器类型 3.3、过滤器使用场景 3.4、过滤器生命周期 3.5、内置过滤器列表 3.6、自定义的过滤器 3.7、禁用指定过滤器 3.8、处理全局的异常 第四章 Zuul其他功能 4.1、负载均衡超时 4.2、服务降级熔断 4.3、网关缓存问题 配套资料,免费下载 链接:https://pan.baidu.com/s/1la_3-HW-UvliDRJzfBcP_w 提取码:lxfx 复制这段内容后打开百度网盘手机App,操作更方便哦 第一章 Zuul介绍 1.1、什么是Zuul 通过前面内容的学习,我们已经可以基本搭建出一套简略版的微服务架构了,我们有注册中心Eureka,可以将服务注册到该注册中心中,我们有Ribbon或Feign或OpenFegin可以实现对服务负载均衡地调用,我们有Hystrix可以实现服务的熔断、降级以及限流以及Dashboard和Turbine来进行服务调用监控。 Zuul是Spring Cloud全家桶中的微服务API网关

使用Harbor搭建企业级docker仓库

Deadly 提交于 2021-02-04 11:38:53
Harbor简介 1.Harbor介绍 Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有Registry中, 确保数据和知识产权在公司内部网络中管控。另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等。 2.Harbor特性 基于角色的访问控制 :用户与Docker镜像仓库通过“项目”进行组织管理,一个用户可以对多个镜像仓库在同一命名空间(project)里有不同的权限。 镜像复制 :镜像可以在多个Registry实例中复制(同步)。尤其适合于负载均衡,高可用,混合云和多云的场景。 图形化用户界面 :用户可以通过浏览器来浏览,检索当前Docker镜像仓库,管理项目和命名空间。 AD/LDAP 支持 :Harbor可以集成企业内部已有的AD/LDAP,用于鉴权认证管理。 审计管理 :所有针对镜像仓库的操作都可以被记录追溯,用于审计管理。 国际化 :已拥有英文、中文、德文、日文和俄文的本地化版本