The trace of the canonical module (the canonical trace) determines the non-Gorenstein locus of a local Cohen-Macaulay ring. We call a local Cohen-Macaulay ring nearly Gorenstein, if its canonical trace contains the maximal ideal. Similar definitions can be made for positively graded Cohen-Macaulay K-algebras. We study the canonical trace for tensor products and Segre products of algebras, as well as of (squarefree) Veronese subalgebras. The results are used to classify the nearly Gorenstein Hibi rings. We also consider the canonical trace of onedimensional rings with a focus on numerical semigroup rings.By using a result of Goto and Watanabe [15] one deduces then from Theorem 4.6 that all Veronese subalgebras of a standard graded K-algebra R over an infinite field K are nearly Gorenstein, if R is Gorenstein.The situation for squarefree Veronese subalgebras is more complicated. Given integers n ≥ d > 0, the d-th squarefree Veronese subalgebra R n,d of the polynomial ring S in n variables over a field K is the K-algebra generated by the squarefree monomials in S of degree d. Based on a theorem of Bruns, Vasconcelos and Villarreal [5] we give in Theorem 4.12 an explicit description of the anti-canonical ideal of R n,d , and we use this result to show in Theorem 4.14 that the following conditions are equivalent: (i) R n,d is nearly Gorenstein, (ii) R n,d is Gorenstein, (iii) d = 1 or d = n − 1 or n = 2d.By another result of Goto and Watanabe [15], the canonical module for the Segre product T = R#S of positively graded Cohen-Macaulay K-algebras R and S of Krull dimension at least 2 is just the Segre product of the respective canonical modules, assuming that T is Cohen-Macaulay. We use this result in Theorem 4.15 to compute tr(ω T ) in the case that R and S are standard graded Gorenstein Kalgebras. It is shown in Theorem 4.15 that m |r−s| T ⊆ tr(ω T ), where m T is the graded maximal ideal of T and where r and s are the respective a-invariants of R and S. Equality holds, if T is a domain. If follows that under these conditions T is nearly Gorenstein if and only if |r − s| ≤ 1, see Corollary 4.16. The section ends with Proposition 4.18 in which the anti-canonical ideal of the Segre product is computed in the case that R and S are polynomial rings.These results on Segre products are used in Section 5 to give a complete classification of all nearly Gorenstein Hibi rings. Given a finite distributive lattice L and a field K, the Hibi ring of L defined over K is the toric ring R K [L] whose relations are the meet-join relations of L. By a fundamental theorem of Birkhoff, L is the ideal lattice J (P ) of its poset of join irreducible elements. It is shown in Theorem 5.4 3